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
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
15 def RunSmoothness(self, action_runner):
16 action_runner.RunAction(ScrollAction())
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)
23 def RunNavigateSteps(self, action_runner):
24 super(Google, self).RunNavigateSteps(action_runner)
25 action_runner.RunAction(WaitAction(
26 {'condition': 'element', 'text': 'Next'}))
29 class Gmail(SimpleScrollPage):
30 def __init__(self, page_set):
31 super(Gmail, self).__init__(
32 url='https://mail.google.com/mail/',
36 def RunNavigateSteps(self, action_runner):
37 super(Gmail, self).RunNavigateSteps(action_runner)
38 action_runner.RunAction(WaitAction(
39 {'javascript' : 'window.gmonkey !== undefined &&'
40 'document.getElementById("gb") !== null'}))
43 class GoogleCalendar(SimpleScrollPage):
44 def __init__(self, page_set):
45 super(GoogleCalendar, self).__init__(
46 url='https://www.google.com/calendar/',
50 def RunNavigateSteps(self, action_runner):
51 super(GoogleCalendar, self).RunNavigateSteps(action_runner)
52 action_runner.RunAction(JavascriptAction(
54 '(function() { var elem = document.createElement("meta");'
55 'elem.name="viewport";'
56 'elem.content="initial-scale=1";'
57 'document.body.appendChild(elem); })();'}))
58 action_runner.RunAction(WaitAction({'seconds' : 2}))
59 action_runner.RunAction(WaitAction({
60 'condition' : 'element', 'selector' : 'div[class~="navForward"]'}))
63 class Youtube(SimpleScrollPage):
64 def __init__(self, page_set):
65 super(Youtube, self).__init__(
66 url='http://www.youtube.com',
70 def RunNavigateSteps(self, action_runner):
71 super(Youtube, self).RunNavigateSteps(action_runner)
72 action_runner.RunAction(WaitAction({'seconds' : 2}))
75 class Facebook(SimpleScrollPage):
76 def __init__(self, page_set):
77 super(Facebook, self).__init__(
78 url='http://www.facebook.com/barackobama',
80 credentials='facebook',
83 def RunNavigateSteps(self, action_runner):
84 super(Facebook, self).RunNavigateSteps(action_runner)
85 action_runner.RunAction(WaitAction(
86 {'condition': 'element', 'text': 'About'}))
89 class Top10PageSet(page_set_module.PageSet):
91 super(Top10PageSet, self).__init__(
92 description='10 Pages chosen from Alexa top sites',
93 archive_data_file='data/top_10.json',
94 credentials_path='data/credentials.json',
95 user_agent_type='desktop')
97 # top google property; a google tab is often open
98 self.AddPage(Google(self))
100 # productivity, top google properties
101 self.AddPage(Gmail(self))
103 # productivity, top google properties
104 self.AddPage(GoogleCalendar(self))
107 self.AddPage(Youtube(self))
109 # top social, Public profile
110 self.AddPage(Facebook(self))
112 # #6 (Alexa) most visited worldwide,Picked an interesting page
113 self.AddPage(SimpleScrollPage('http://en.wikipedia.org/wiki/Wikipedia',
114 self, name='Wikipedia'))
116 # #1 world commerce website by visits; #3 commerce in the US by time spent
117 self.AddPage(SimpleScrollPage('http://www.amazon.com', self))
120 self.AddPage(SimpleScrollPage('http://www.yahoo.com/', self))
123 self.AddPage(SimpleScrollPage('http://www.bing.com/', self))
126 self.AddPage(SimpleScrollPage('http://www.ask.com/', self))