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 from telemetry
.page
import page
as page_module
5 from telemetry
.page
import page_set
as page_set_module
8 class SimpleScrollPage(page_module
.Page
):
9 def __init__(self
, url
, page_set
, credentials
='', name
=''):
10 super(SimpleScrollPage
, self
).__init
__(
11 url
, page_set
=page_set
, name
=name
,
12 credentials_path
='data/credentials.json')
13 self
.credentials
= credentials
15 def RunSmoothness(self
, action_runner
):
16 interaction
= action_runner
.BeginGestureInteraction(
17 'ScrollAction', is_smooth
=True)
18 action_runner
.ScrollPage()
21 class Google(SimpleScrollPage
):
22 def __init__(self
, page_set
):
23 super(Google
, self
).__init
__(
24 url
='https://www.google.com/#hl=en&q=barack+obama', page_set
=page_set
)
26 def RunNavigateSteps(self
, action_runner
):
27 super(Google
, self
).RunNavigateSteps(action_runner
)
28 action_runner
.WaitForElement(text
='Next')
31 class Gmail(SimpleScrollPage
):
32 def __init__(self
, page_set
):
33 super(Gmail
, self
).__init
__(
34 url
='https://mail.google.com/mail/',
38 def RunNavigateSteps(self
, action_runner
):
39 super(Gmail
, self
).RunNavigateSteps(action_runner
)
40 action_runner
.WaitForJavaScriptCondition(
41 'window.gmonkey !== undefined &&'
42 'document.getElementById("gb") !== null')
45 class GoogleCalendar(SimpleScrollPage
):
46 def __init__(self
, page_set
):
47 super(GoogleCalendar
, self
).__init
__(
48 url
='https://www.google.com/calendar/',
52 def RunNavigateSteps(self
, action_runner
):
53 super(GoogleCalendar
, self
).RunNavigateSteps(action_runner
)
54 action_runner
.ExecuteJavaScript('''
55 (function() { var elem = document.createElement("meta");
57 elem.content="initial-scale=1";
58 document.body.appendChild(elem);
61 action_runner
.WaitForElement('div[class~="navForward"]')
64 class Youtube(SimpleScrollPage
):
65 def __init__(self
, page_set
):
66 super(Youtube
, self
).__init
__(
67 url
='http://www.youtube.com',
71 def RunNavigateSteps(self
, action_runner
):
72 super(Youtube
, self
).RunNavigateSteps(action_runner
)
76 class Facebook(SimpleScrollPage
):
77 def __init__(self
, page_set
):
78 super(Facebook
, self
).__init
__(
79 url
='http://www.facebook.com/barackobama',
81 credentials
='facebook',
84 def RunNavigateSteps(self
, action_runner
):
85 super(Facebook
, self
).RunNavigateSteps(action_runner
)
86 action_runner
.WaitForElement(text
='About')
89 class Top10PageSet(page_set_module
.PageSet
):
90 """10 Pages chosen from Alexa top sites"""
93 super(Top10PageSet
, self
).__init
__(
94 archive_data_file
='data/top_10.json',
95 user_agent_type
='desktop',
96 bucket
=page_set_module
.PARTNER_BUCKET
)
98 # top google property; a google tab is often open
99 self
.AddPage(Google(self
))
101 # productivity, top google properties
102 # TODO(dominikg): fix crbug.com/386152
103 #self.AddPage(Gmail(self))
105 # productivity, top google properties
106 self
.AddPage(GoogleCalendar(self
))
109 self
.AddPage(Youtube(self
))
111 # top social, Public profile
112 self
.AddPage(Facebook(self
))
114 # #6 (Alexa) most visited worldwide,Picked an interesting page
115 self
.AddPage(SimpleScrollPage('http://en.wikipedia.org/wiki/Wikipedia',
116 self
, name
='Wikipedia'))
118 # #1 world commerce website by visits; #3 commerce in the US by time spent
119 self
.AddPage(SimpleScrollPage('http://www.amazon.com', self
))
122 self
.AddPage(SimpleScrollPage('http://www.yahoo.com/', self
))
125 self
.AddPage(SimpleScrollPage('http://www.bing.com/', self
))
128 self
.AddPage(SimpleScrollPage('http://www.ask.com/', self
))