Chromium Code Reviews| Index: tools/perf/page_sets/system_health/searching_stories.py |
| diff --git a/tools/perf/page_sets/system_health/searching_stories.py b/tools/perf/page_sets/system_health/searching_stories.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..32549c11fe519b739662b13706cee33cfa6e9a78 |
| --- /dev/null |
| +++ b/tools/perf/page_sets/system_health/searching_stories.py |
| @@ -0,0 +1,46 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +from page_sets.system_health import system_health_story |
| + |
| + |
| +class SearchGoogleStory(system_health_story.SystemHealthStory): |
| + NAME = 'search:search:google' |
|
nednguyen
2016/07/20 20:44:25
search:portal:google?
petrcermak
2016/07/22 16:16:25
Done.
|
| + URL = 'https://www.google.co.uk/' |
| + |
| + _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| + _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + # Click on the search box. |
| + action_runner.Wait(1) |
| + action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
| + action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) |
| + |
| + # Submit search query. |
| + action_runner.Wait(1) |
| + action_runner.EnterText('what is science') |
| + action_runner.Wait(0.5) |
| + action_runner.PressKey('Return') |
| + |
| + # Scroll to the Wikipedia result. |
| + action_runner.Wait(1) |
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| + action_runner.WaitForElement(selector=self._RESULT_SELECTOR) |
| + # TODO(petrcermak): Turn this into a proper Telemetry API (ScrollToElement). |
|
nednguyen
2016/07/20 16:02:02
Yeah, I encounter this situation a lot too ~_~
|
| + result_visible_expression = (''' |
| + (function() { |
| + var resultElem = document.querySelector(\'%s\'); |
| + var boundingRect = resultElem.getBoundingClientRect(); |
| + return boundingRect.bottom >= window.innerHeight |
| + })()''' % self._RESULT_SELECTOR) |
| + while action_runner.EvaluateJavaScript(result_visible_expression): |
| + action_runner.RepeatableBrowserDrivenScroll(y_scroll_distance_ratio=0.75, |
| + prevent_fling=False) |
| + action_runner.Wait(0.2) |
| + |
| + # Click on the Wikipedia result. |
| + action_runner.Wait(1) |
| + action_runner.TapElement(selector=self._RESULT_SELECTOR) |
| + action_runner.tab.WaitForDocumentReadyStateToBeComplete() |