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