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 shared_page_state
6 from telemetry
import story
9 class SimplePage(page_module
.Page
):
10 def __init__(self
, url
, page_set
, credentials
='', name
=''):
11 super(SimplePage
, self
).__init
__(
12 url
, page_set
=page_set
, name
=name
,
13 credentials_path
='data/credentials.json',
14 shared_page_state_class
=shared_page_state
.SharedDesktopPageState
)
15 self
.credentials
= credentials
17 def RunPageInteractions(self
, action_runner
):
21 class Google(SimplePage
):
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(SimplePage
):
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(SimplePage
):
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(SimplePage
):
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(SimplePage
):
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(story
.StorySet
):
90 """10 Pages chosen from Alexa top sites"""
93 super(Top10PageSet
, self
).__init
__(
94 archive_data_file
='data/top_10.json',
95 cloud_storage_bucket
=story
.PARTNER_BUCKET
)
97 # top google property; a google tab is often open
98 self
.AddStory(Google(self
))
100 # productivity, top google properties
101 # TODO(dominikg): fix crbug.com/386152
102 #self.AddStory(Gmail(self))
104 # productivity, top google properties
105 self
.AddStory(GoogleCalendar(self
))
108 self
.AddStory(Youtube(self
))
110 # top social, Public profile
111 self
.AddStory(Facebook(self
))
113 # #6 (Alexa) most visited worldwide,Picked an interesting page
114 self
.AddStory(SimplePage('http://en.wikipedia.org/wiki/Wikipedia',
115 self
, name
='Wikipedia'))
117 # #1 world commerce website by visits; #3 commerce in the US by time spent
118 self
.AddStory(SimplePage('http://www.amazon.com', self
))
121 self
.AddStory(SimplePage('http://www.yahoo.com/', self
))
124 self
.AddStory(SimplePage('http://www.bing.com/', self
))
127 self
.AddStory(SimplePage('http://www.ask.com/', self
))