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

Unified Diff: tools/perf/page_sets/system_health/searching_stories.py

Issue 2148843002: [system-health] Add full Google Search story to the System Health story sets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move back to searching_stories.py & rebase Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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()

Powered by Google App Engine
This is Rietveld 408576698