Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2014 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 telemetry.page.actions.javascript import JavascriptAction | |
| 6 from telemetry.page.actions.navigate import NavigateAction | |
| 7 from telemetry.page.actions.scroll import ScrollAction | |
| 8 from telemetry.page.actions.wait import WaitAction | |
| 9 from telemetry.page.python_page_set import PythonPageSet | |
| 10 from telemetry.page.page import Page | |
| 11 | |
| 12 class ScrollPage(Page): | |
| 13 def __init__(self, url='', navigate_steps=None, credentials=''): | |
| 14 super(ScrollPage, self).__init__(url, '') | |
| 15 if not navigate_steps: | |
| 16 self._navigate_steps = [] | |
| 17 else: | |
| 18 self._navigate_steps = navigate_steps | |
| 19 | |
| 20 @property | |
| 21 def navigate_steps(): | |
| 22 return self._navigate_steps | |
| 23 | |
| 24 @property | |
| 25 def smoothness(): | |
| 26 return [ScrollAction()] | |
| 27 | |
| 28 class Top10(PythonPageSet): | |
| 29 def __init__(self): | |
| 30 super(Top10, self).__init__( | |
| 31 description='10 Pages chosen from Alexa top sites', | |
| 32 archive_data_file='data/top_10.json', | |
| 33 credentials_path='data/credentials.json', | |
| 34 user_agent_type='desktop') | |
| 35 | |
| 36 self.AddPages( | |
| 37 #top google property; a google tab is often open | |
|
nduca
2014/02/27 18:26:57
from our chat
class Top10(PageSet):
def __init_
nednguyen
2014/02/27 19:49:33
Done.
| |
| 38 ScrollPage(url='https://www.google.com/#hl=en&q=barack+obama', | |
| 39 navigate_steps=[ | |
| 40 NavigateAction(), | |
| 41 WaitAction().UntilTextElementAvailable(text='Next')]), | |
| 42 #productivity, top google properties | |
| 43 ScrollPage(url='https://mail.google.com/mail/', | |
| 44 navigate_steps=[ | |
| 45 NavigateAction(), | |
| 46 WaitAction.UntilTrue( | |
| 47 expression='''window.gmonkey !== undefined && | |
| 48 document.getElementById('gb') !== null''')]), | |
| 49 #productivity, top google properties | |
| 50 ScrollPage(url='https://google.com/calendar/', | |
| 51 navigate_steps=[ | |
| 52 NavigateAction(), | |
| 53 JavascriptAction().OfExpression( | |
| 54 '''(function() { var elem = document.createElement("meta"); | |
| 55 elem.name="viewport"; | |
| 56 elem.content="initial-scale=1"; | |
| 57 document.body.appendChild(elem); })();'''), | |
| 58 WaitAction().ForSeconds(2), | |
| 59 WaitAction().UntilSelectorElementAvailable( | |
| 60 selector='div[class~="navForward"]')], | |
| 61 credentials='google')) | |
| OLD | NEW |