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..156c614fb2bc7b0ceeac4f5a53a25f603cdefc7c |
--- /dev/null |
+++ b/tools/perf/page_sets/system_health/searching_stories.py |
@@ -0,0 +1,45 @@ |
+# 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:portal:google' |
+ 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.WaitForElement(selector=self._RESULT_SELECTOR) |
+ action_runner.Wait(1) |
+ # TODO(petrcermak): Turn this into a proper Telemetry API (ScrollToElement). |
+ 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() |