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.page_set import PageSet | |
| 10 from telemetry.page.page import Page | |
| 11 | |
| 12 class SimpleScrollPage(Page): | |
| 13 def __init__(self, url='', credentials=''): | |
| 14 super(SimpleScrollPage, self).__init__(url, '') | |
| 15 self.credentials = credentials | |
| 16 | |
| 17 def RunNavigateSteps(self, action_runner): | |
| 18 action_runner.RunAction(NavigateAction()) | |
| 19 | |
| 20 def RunSmoothness(self, action_runner): | |
| 21 action_runner.RunAction(ScrollAction()) | |
| 22 | |
| 23 class PageSetTop10(PageSet): | |
| 24 def __init__(self): | |
| 25 super(PageSetTop10, self).__init__( | |
| 26 description='10 Pages chosen from Alexa top sites', | |
| 27 archive_data_file='data/top_10.json', | |
| 28 credentials_path='data/credentials.json', | |
| 29 user_agent_type='desktop') | |
| 30 | |
| 31 # top google property; a google tab is often open | |
| 32 class Google(SimpleScrollPage): | |
| 33 def __init__(self): | |
| 34 super(Google, self).__init__( | |
| 35 'https://www.google.com/#hl=en&q=barack+obama') | |
| 36 | |
| 37 def RunNavigateSteps(self, action_runner): | |
| 38 super(Google, self).navigate_steps(action_runner) | |
| 39 action_runner.RunAction(WaitAction(). | |
| 40 UntilTextElementAvailable(text='Next')) | |
| 41 | |
| 42 self.AddPage(Google()) | |
| 43 | |
| 44 # productivity, top google properties | |
| 45 class Gmail(SimpleScrollPage): | |
| 46 def __init__(self): | |
| 47 super(Gmail, self).__init__( | |
| 48 'https://mail.google.com/mail/', credentials='google') | |
| 49 | |
| 50 def RunNavigateSteps(self, action_runner): | |
| 51 super(Gmail, self).navigate_steps(action_runner) | |
| 52 action_runner.RunAction(WaitAction().UntilTrue( | |
| 53 'window.gmonkey !== undefined &&' | |
| 54 'document.getElementById("gb") !== null')) | |
| 55 | |
| 56 self.AddPage(Gmail()) | |
| 57 | |
| 58 # productivity, top google properties | |
| 59 class GoogleCalendar(SimpleScrollPage): | |
| 60 def __init__(self): | |
| 61 super(GoogleCalendar, self).__init__( | |
| 62 'https://www.google.com/calendar/', credentials='google') | |
| 63 | |
| 64 def RunNavigateSteps(self, action_runner): | |
| 65 super(GoogleCalendar, self).navigate_steps(action_runner) | |
| 66 action_runner.RunAction(JavascriptAction().OfExpression( | |
| 67 '(function() { var elem = document.createElement("meta");' | |
| 68 'elem.name="viewport";' | |
| 69 'elem.content="initial-scale=1";' | |
| 70 'document.body.appendChild(elem); })();')) | |
| 71 action_runner.RunAction(WaitAction().ForSeconds(2)) | |
| 72 action_runner.RunAction(WaitAction().UntilSelectorElementAvailable( | |
| 73 selector='div[class~="navForward"]')) | |
| 74 | |
| 75 self.AddPage(GoogleCalendar()) | |
| 76 | |
| 77 # #3 (Alexa global) | |
| 78 class Youtube(SimpleScrollPage): | |
| 79 def __init__(self): | |
| 80 super(Youtube, self).__init__( | |
| 81 'https://www.youtube.com', credentials='google') | |
| 82 | |
| 83 def RunNavigateSteps(self, action_runner): | |
| 84 super(Youtube, self).RunNavigateSteps(action_runner) | |
| 85 action_runner.RunAction(WaitAction().ForSeconds(2)) | |
| 86 | |
| 87 self.AddPage(Youtube()) | |
| 88 | |
| 89 # top social, Public profile | |
| 90 class Facebook(SimpleScrollPage): | |
|
nduca
2014/03/05 01:10:43
mind hoisting these inner classes out to toplevel?
nednguyen
2014/03/05 20:53:31
Done.
| |
| 91 def __init__(self): | |
| 92 super(Facebook, self).__init__( | |
| 93 'http://www.facebook.com/barackobama', credentials='facebook') | |
| 94 | |
| 95 def RunNavigateSteps(self, action_runner): | |
| 96 super(Facebook, self).RunNavigateSteps(action_runner) | |
| 97 action_runner.RunAction(WaitAction().UntilTextElementAvailable("About")) | |
| 98 | |
| 99 self.AddPage(Facebook()) | |
| 100 | |
| 101 # #6 (Alexa) most visited worldwide,Picked an interesting page | |
| 102 self.AddPage(SimpleScrollPage('http://en.wikipedia.org/wiki/Wikipedia')) | |
| 103 # #1 world commerce website by visits; #3 commerce in the US by time spent | |
| 104 self.AddPage(SimpleScrollPage('http://www.amazon.com')) | |
| 105 # #4 Alexa | |
| 106 self.AddPage(SimpleScrollPage('http://www.yahoo.com/')) | |
| 107 # #16 Alexa | |
| 108 self.AddPage(SimpleScrollPage('http://www.bing.com/')) | |
| 109 # #20 Alexa | |
| 110 self.AddPage(SimpleScrollPage('http://www.ask.com/')) | |
| OLD | NEW |