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

Side by Side 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: Rebase Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/system_health/loading_stories.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 from page_sets.system_health import system_health_story
6
7
8 class SearchGoogleStory(system_health_story.SystemHealthStory):
9 NAME = 'search:portal:google'
10 URL = 'https://www.google.co.uk/'
11
12 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]'
13 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]'
14
15 def _DidLoadDocument(self, action_runner):
16 # Click on the search box.
17 action_runner.Wait(1)
18 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR)
19 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR)
20
21 # Submit search query.
22 action_runner.Wait(1)
23 action_runner.EnterText('what is science')
24 action_runner.Wait(0.5)
25 action_runner.PressKey('Return')
26
27 # Scroll to the Wikipedia result.
28 action_runner.WaitForElement(selector=self._RESULT_SELECTOR)
29 action_runner.Wait(1)
30 # TODO(petrcermak): Turn this into a proper Telemetry API (ScrollToElement).
31 result_visible_expression = ('''
32 (function() {
33 var resultElem = document.querySelector(\'%s\');
34 var boundingRect = resultElem.getBoundingClientRect();
35 return boundingRect.bottom >= window.innerHeight
36 })()''' % self._RESULT_SELECTOR)
37 while action_runner.EvaluateJavaScript(result_visible_expression):
38 action_runner.RepeatableBrowserDrivenScroll(y_scroll_distance_ratio=0.75,
39 prevent_fling=False)
40 action_runner.Wait(0.2)
41
42 # Click on the Wikipedia result.
43 action_runner.Wait(1)
44 action_runner.TapElement(selector=self._RESULT_SELECTOR)
45 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
OLDNEW
« no previous file with comments | « tools/perf/page_sets/system_health/loading_stories.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698