Chromium Code Reviews| 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 |
| 7 | 9 |
| 8 class SearchGoogleStory(system_health_story.SystemHealthStory): | 10 class SearchGoogleStory(system_health_story.SystemHealthStory): |
| 9 NAME = 'search:portal:google' | 11 NAME = 'search:portal:google' |
| 10 URL = 'https://www.google.co.uk/' | 12 URL = 'https://www.google.co.uk/' |
| 13 TAGS = [story_tags.EMERGING_MARKET] | |
| 11 | 14 |
| 12 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' | 15 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| 13 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' | 16 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' |
| 14 | 17 |
| 15 def _DidLoadDocument(self, action_runner): | 18 def _DidLoadDocument(self, action_runner): |
| 16 # Click on the search box. | 19 # Click on the search box. |
| 17 action_runner.Wait(1) | 20 action_runner.Wait(1) |
| 18 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) | 21 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
| 19 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) | 22 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) |
| 20 | 23 |
| 21 # Submit search query. | 24 # Submit search query. |
| 22 action_runner.Wait(1) | 25 action_runner.Wait(1) |
| 23 action_runner.EnterText('what is science') | 26 action_runner.EnterText('what is science') |
| 24 action_runner.Wait(0.5) | 27 action_runner.Wait(0.5) |
| 25 action_runner.PressKey('Return') | 28 action_runner.PressKey('Return') |
| 26 | 29 |
| 27 # Scroll to the Wikipedia result. | 30 # Scroll to the Wikipedia result. |
| 28 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) | 31 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) |
| 29 action_runner.Wait(1) | 32 action_runner.Wait(1) |
| 30 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) | 33 action_runner.ScrollPageToElement(selector=self._RESULT_SELECTOR) |
| 31 | 34 |
| 32 # Click on the Wikipedia result. | 35 # Click on the Wikipedia result. |
| 33 action_runner.Wait(1) | 36 action_runner.Wait(1) |
| 34 action_runner.TapElement(selector=self._RESULT_SELECTOR) | 37 action_runner.TapElement(selector=self._RESULT_SELECTOR) |
| 35 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 38 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 39 | |
| 40 class SearchOmniboxStory(system_health_story.SystemHealthStory): | |
| 41 NAME = 'search:google:omnibox' | |
| 42 URL = 'https://www.google.co.in' | |
| 43 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 44 TAGS = [story_tags.EMERGING_MARKET] | |
| 45 | |
| 46 def RunPageInteractions(self, action_runner): | |
| 47 platform = action_runner.tab.browser.platform | |
| 48 package = action_runner.tab.browser.GetBrowserInfo().package_name | |
| 49 platform.system_ui.WaitForUiNode(resource_id=package+':id/url_bar') | |
| 50 url_bar = platform.system_ui.GetUiNode(resource_id=package+':id/url_bar') | |
| 51 url_bar.Tap() | |
| 52 action_runner.Wait(1) | |
| 53 platform.android_action_runner.InputText('drake') | |
| 54 action_runner.Wait(0.5) | |
| 55 platform.android_action_runner.InputKeyEvent(66) | |
|
perezju
2017/04/04 09:23:38
use the constant name from:
https://github.com/cat
ssid
2017/04/04 20:59:49
Done.
| |
| 56 | |
| 57 action_runner.WaitForNavigate(15) | |
| 58 action_runner.ScrollPage(use_touch=True, distance=500) | |
| OLD | NEW |