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