Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: tools/perf/page_sets/system_health/searching_stories.py

Issue 2902513002: [System Health] Tidy up stories for Chrome's special pages (Closed)
Patch Set: restore previous browse:search:google Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/system_health/chrome_stories.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 from page_sets.system_health import platforms
6 from page_sets.system_health import story_tags
7 from page_sets.system_health import system_health_story
8
9 from telemetry import decorators
10
11 from devil.android.sdk import keyevent # pylint: disable=import-error
12
13
14 # TODO(ssid): Rename the search stories to browse stories crbug.com/708300.
15 class SearchGoogleStory(system_health_story.SystemHealthStory):
16 """ A typical Google search user story.
17 Issue the search query "what is science" in the search box and press Enter.
18 Wait for the search result page to be loaded, then scroll to the Wikipedia
19 result.
20 Navigate to wikipedia page by clicking on the result and wait for it to be
21 fully loaded.
22 """
23 NAME = 'search:portal:google'
24 URL = 'https://www.google.co.uk/'
25 TAGS = [story_tags.EMERGING_MARKET]
26
27 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]'
28 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]'
29
30 def _DidLoadDocument(self, action_runner):
31 # Click on the search box.
32 action_runner.Wait(1)
33 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR)
34 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR)
35
36 # Submit search query.
37 action_runner.Wait(1)
38 action_runner.EnterText('what is science')
39 action_runner.Wait(0.5)
40 action_runner.PressKey('Return')
41
42 # Scroll to the Wikipedia result.
43 action_runner.WaitForElement(selector=self._RESULT_SELECTOR)
44 action_runner.Wait(1)
45 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR)
46
47 # Click on the Wikipedia result.
48 action_runner.Wait(1)
49 action_runner.TapElement(selector=self._RESULT_SELECTOR)
50 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
51
52
53 @decorators.Disabled('android-webview') # Webview does not have omnibox
54 class SearchOmniboxStory(system_health_story.SystemHealthStory):
55 """Story that peforms search by using omnibox search provider
56
57 Loads a website and enters a search query on omnibox and navigates to default
58 search provider (google).
59 """
60 NAME = 'browse:chrome:omnibox'
61 URL = 'https://www.google.co.in'
62 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
63 TAGS = [story_tags.EMERGING_MARKET]
64
65 def _DidLoadDocument(self, action_runner):
66 app_ui = action_runner.tab.browser.GetAppUi()
67 platform = action_runner.tab.browser.platform
68 app_ui.WaitForUiNode(resource_id='url_bar')
69 url_bar = app_ui.GetUiNode(resource_id='url_bar')
70 url_bar.Tap()
71 action_runner.Wait(1) # user wait before typing
72 platform.android_action_runner.InputText('drake')
73 action_runner.Wait(0.5) # user wait after typing
74 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER)
75
76 action_runner.WaitForNavigate()
77 action_runner.ScrollPage(use_touch=True, distance=500)
78
79
80 @decorators.Disabled('android-webview') # Webview does not have new tab page.
81 class MobileNewTabPageStory(system_health_story.SystemHealthStory):
82 """Story that loads new tab page and performs searches.
83
84 Given a list of typical search queries, this story does for each of them:
85 - enter the search query on the new tab page search box
86 - read results
87 - navigates back to new tab page
88 """
89 NAME = 'browse:chrome:newtab'
90 URL = 'chrome://newtab'
91 _SEARCH_TEXTS = ['does google know everything',
92 'most famous paintings',
93 'current weather',
94 'best movies 2016',
95 'how to tie a tie']
96
97 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
98 TAGS = [story_tags.EMERGING_MARKET]
99
100 def _DidLoadDocument(self, action_runner):
101 app_ui = action_runner.tab.browser.GetAppUi()
102 platform = action_runner.tab.browser.platform
103 for keyword in self._SEARCH_TEXTS:
104 app_ui.WaitForUiNode(resource_id='search_box').Tap()
105 platform.android_action_runner.InputText(keyword)
106 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER)
107 action_runner.WaitForNavigate()
108 action_runner.Wait(1.5) # Read results
109 action_runner.ScrollPage(use_touch=True)
110 action_runner.NavigateBack()
111 action_runner.WaitForNavigate()
112
113 app_ui.WaitForUiNode(resource_id='menu_button').Tap()
114 app_ui.WaitForUiNode(resource_id='menu_item_text')
OLDNEW
« no previous file with comments | « tools/perf/page_sets/system_health/chrome_stories.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698