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