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 import logging | 5 import logging |
| 6 import sys | 6 import sys |
| 7 | 7 |
| 8 from page_sets.login_helpers import dropbox_login | 8 from page_sets.login_helpers import dropbox_login |
| 9 from page_sets.login_helpers import google_login | 9 from page_sets.login_helpers import google_login |
| 10 | 10 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 yield cls | 79 yield cls |
| 80 | 80 |
| 81 | 81 |
| 82 ################################################################################ | 82 ################################################################################ |
| 83 # Search and e-commerce. | 83 # Search and e-commerce. |
| 84 ################################################################################ | 84 ################################################################################ |
| 85 | 85 |
| 86 | 86 |
| 87 class LoadGoogleStory(_SinglePageStory): | 87 class LoadGoogleStory(_SinglePageStory): |
| 88 NAME = 'load:search:google' | 88 NAME = 'load:search:google' |
| 89 URL = 'https://www.google.com/#hl=en&q=science' | 89 URL = 'https://www.google.co.uk/' |
| 90 | |
| 91 | |
| 92 class SearchGoogleStory(_SinglePageStory): | |
|
petrcermak
2016/07/13 15:47:15
I'll move this to a separate file (search_stories.
| |
| 93 NAME = 'search:search:google' | |
|
petrcermak
2016/07/13 15:47:15
I'm still not completely sure about the names:
1.
nednguyen
2016/07/13 16:03:24
This seems like it a type of browsing stories so s
petrcermak
2016/07/14 13:20:15
Done.
nednguyen
2016/07/14 13:25:17
Now that I know search is a major activity that pe
| |
| 94 URL = 'https://www.google.co.uk/' | |
| 95 | |
| 96 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' | |
| 97 _RESULT_SELECTOR = '.r > a[href*="wikipedia"]' | |
| 98 | |
| 99 def _DidLoadDocument(self, action_runner): | |
| 100 # Click on the search box. | |
| 101 action_runner.Wait(1) | |
| 102 action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) | |
| 103 action_runner.TapElement(selector=self._SEARCH_BOX_SELECTOR) | |
| 104 | |
| 105 # Submit search query. | |
| 106 action_runner.Wait(1) | |
| 107 action_runner.EnterText('what is science') | |
| 108 action_runner.Wait(0.5) | |
| 109 action_runner.PressKey('Return') | |
| 110 | |
| 111 # Scroll to the Wikipedia result. | |
| 112 action_runner.Wait(1) | |
| 113 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
| 114 action_runner.WaitForElement(selector=self._RESULT_SELECTOR) | |
| 115 # TODO(petrcermak): Turn this into a proper Telemetry API (ScrollToElement). | |
| 116 result_visible_expression = (''' | |
| 117 (function() { | |
| 118 var resultElem = document.querySelector(\'%s\'); | |
| 119 var boundingRect = resultElem.getBoundingClientRect(); | |
| 120 return boundingRect.bottom >= window.innerHeight | |
| 121 })()''' % self._RESULT_SELECTOR) | |
| 122 while action_runner.EvaluateJavaScript(result_visible_expression): | |
|
petrcermak
2016/07/13 15:47:15
Note that we can't a single RepeatableBrowserDrive
| |
| 123 action_runner.RepeatableBrowserDrivenScroll(y_scroll_distance_ratio=0.75, | |
| 124 prevent_fling=False) | |
| 125 action_runner.Wait(0.2) | |
| 126 | |
| 127 # Click on the Wikipedia result. | |
| 128 action_runner.Wait(1) | |
| 129 action_runner.TapElement(selector=self._RESULT_SELECTOR) | |
| 130 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
| 90 | 131 |
| 91 | 132 |
| 92 class LoadBaiduStory(_SinglePageStory): | 133 class LoadBaiduStory(_SinglePageStory): |
| 93 NAME = 'load:search:baidu' | 134 NAME = 'load:search:baidu' |
| 94 URL = 'https://www.baidu.com/s?word=google' | 135 URL = 'https://www.baidu.com/s?word=google' |
| 95 | 136 |
| 96 | 137 |
| 97 class LoadYahooStory(_SinglePageStory): | 138 class LoadYahooStory(_SinglePageStory): |
| 98 NAME = 'load:search:yahoo' | 139 NAME = 'load:search:yahoo' |
| 99 URL = 'https://search.yahoo.com/search;_ylt=?p=google' | 140 URL = 'https://search.yahoo.com/search;_ylt=?p=google' |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 URL = 'http://www.miniclip.com/games/en/' | 439 URL = 'http://www.miniclip.com/games/en/' |
| 399 # Desktop only (requires Flash). | 440 # Desktop only (requires Flash). |
| 400 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 441 SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
| 401 | 442 |
| 402 | 443 |
| 403 class LoadAlphabettyStory(_SinglePageStory): | 444 class LoadAlphabettyStory(_SinglePageStory): |
| 404 NAME = 'load:games:alphabetty' | 445 NAME = 'load:games:alphabetty' |
| 405 URL = 'https://king.com/play/alphabetty' | 446 URL = 'https://king.com/play/alphabetty' |
| 406 # Desktop only (requires Flash). | 447 # Desktop only (requires Flash). |
| 407 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 448 SUPPORTED_PLATFORMS = _DESKTOP_ONLY |
| OLD | NEW |