OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from page_sets.system_health import platforms | |
6 from page_sets.system_health import story_tags | |
5 from page_sets.system_health import system_health_story | 7 from page_sets.system_health import system_health_story |
6 | 8 |
9 from devil.android.sdk import keyevent # pylint: disable=import-error | |
7 | 10 |
11 | |
12 # TODO(ssid): Rename the search stories to browse stories crbug.com/708300. | |
8 class SearchGoogleStory(system_health_story.SystemHealthStory): | 13 class SearchGoogleStory(system_health_story.SystemHealthStory): |
9 NAME = 'search:portal:google' | 14 NAME = 'search:portal:google' |
10 URL = 'https://www.google.co.uk/' | 15 URL = 'https://www.google.co.uk/' |
16 TAGS = [story_tags.EMERGING_MARKET] | |
11 | 17 |
12 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' | 18 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
13 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' | 19 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' |
14 | 20 |
15 def _DidLoadDocument(self, action_runner): | 21 def _DidLoadDocument(self, action_runner): |
16 # Click on the search box. | 22 # Click on the search box. |
17 action_runner.Wait(1) | 23 action_runner.Wait(1) |
18 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) | 24 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
19 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) | 25 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) |
20 | 26 |
21 # Submit search query. | 27 # Submit search query. |
22 action_runner.Wait(1) | 28 action_runner.Wait(1) |
23 action_runner.EnterText('what is science') | 29 action_runner.EnterText('what is science') |
24 action_runner.Wait(0.5) | 30 action_runner.Wait(0.5) |
25 action_runner.PressKey('Return') | 31 action_runner.PressKey('Return') |
26 | 32 |
27 # Scroll to the Wikipedia result. | 33 # Scroll to the Wikipedia result. |
28 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) | 34 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) |
29 action_runner.Wait(1) | 35 action_runner.Wait(1) |
30 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) | 36 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) |
31 | 37 |
32 # Click on the Wikipedia result. | 38 # Click on the Wikipedia result. |
33 action_runner.Wait(1) | 39 action_runner.Wait(1) |
34 action_runner.TapElement(selector=self._RESULT_SELECTOR) | 40 action_runner.TapElement(selector=self._RESULT_SELECTOR) |
35 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 41 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
42 | |
43 | |
44 class SearchOmniboxStory(system_health_story.SystemHealthStory): | |
45 """Story that peforms search by using omnibox search provider | |
46 | |
47 Loads a website and enters a search query on omnibox and navigates to default | |
48 search provider (google). | |
49 """ | |
50 NAME = 'browse:chrome:omnibox' | |
51 URL = 'https://www.google.co.in' | |
52 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
53 TAGS = [story_tags.EMERGING_MARKET] | |
54 | |
55 def _DidLoadDocument(self, action_runner): | |
56 app_ui = action_runner.tab.browser.GetAppUi() | |
57 platform = action_runner.tab.browser.platform | |
58 app_ui.WaitForUiNode(resource_id='url_bar') | |
59 url_bar = app_ui.GetUiNode(resource_id='url_bar') | |
60 url_bar.Tap() | |
61 action_runner.Wait(1) # user wait before typing | |
62 platform.android_action_runner.InputText('drake') | |
63 action_runner.Wait(0.5) # user wait after typing | |
64 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) | |
65 | |
66 action_runner.WaitForNavigate() | |
67 action_runner.ScrollPage(use_touch=True, distance=500) | |
68 | |
69 | |
70 class MobileNewTabPageStory(system_health_story.SystemHealthStory): | |
71 """Story that loads new tab page and performs searches. | |
72 | |
73 This story does in a loop: | |
nednguyen
2017/04/17 19:20:28
nits: change this to:
"For each of the search quer
ssid
2017/04/17 20:37:05
Done.
| |
74 - enter a search query from new tab page | |
75 - read results | |
76 - navigates back to new tab page | |
77 """ | |
78 | |
79 NAME = 'browse:chrome:newtab' | |
80 URL = 'chrome://newtab' | |
81 _SEARCH_TEXTS = ['does google know everything', | |
82 'most famous paintings', | |
83 'current weather', | |
84 'best movies 2016', | |
85 'how to tie a tie'] | |
86 | |
87 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
88 TAGS = [story_tags.EMERGING_MARKET] | |
89 | |
90 def _DidLoadDocument(self, action_runner): | |
91 app_ui = action_runner.tab.browser.GetAppUi() | |
92 platform = action_runner.tab.browser.platform | |
93 for keyword in self._SEARCH_TEXTS: | |
94 app_ui.WaitForUiNode(resource_id='search_box').Tap() | |
95 platform.android_action_runner.InputText(keyword) | |
96 platform.android_action_runner.InputKeyEvent(keyevent.KEYCODE_ENTER) | |
97 action_runner.WaitForNavigate() | |
98 action_runner.Wait(1.5) # Read results | |
99 action_runner.ScrollPage(use_touch=True) | |
100 action_runner.NavigateBack() | |
101 action_runner.WaitForNavigate() | |
102 | |
103 app_ui.WaitForUiNode(resource_id='menu_button').Tap() | |
104 app_ui.WaitForUiNode(resource_id='menu_item_text') | |
OLD | NEW |