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 SimplePage(page_module
.Page
):
9 def __init__(self
, url
, page_set
, credentials
='', name
=''):
10 super(SimplePage
, self
).__init
__(
11 url
, page_set
=page_set
, name
=name
,
12 credentials_path
='data/credentials.json')
13 self
.credentials
= credentials
15 def RunPageInteractions(self
, action_runner
):
18 class Google(SimplePage
):
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
.WaitForElement(text
='Next')
28 class Gmail(SimplePage
):
29 def __init__(self
, page_set
):
30 super(Gmail
, self
).__init
__(
31 url
='https://mail.google.com/mail/',
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')
42 class GoogleCalendar(SimplePage
):
43 def __init__(self
, page_set
):
44 super(GoogleCalendar
, self
).__init
__(
45 url
='https://www.google.com/calendar/',
49 def RunNavigateSteps(self
, action_runner
):
50 super(GoogleCalendar
, self
).RunNavigateSteps(action_runner
)
51 action_runner
.ExecuteJavaScript('''
52 (function() { var elem = document.createElement("meta");
54 elem.content="initial-scale=1";
55 document.body.appendChild(elem);
58 action_runner
.WaitForElement('div[class~="navForward"]')
61 class Youtube(SimplePage
):
62 def __init__(self
, page_set
):
63 super(Youtube
, self
).__init
__(
64 url
='http://www.youtube.com',
68 def RunNavigateSteps(self
, action_runner
):
69 super(Youtube
, self
).RunNavigateSteps(action_runner
)
73 class Facebook(SimplePage
):
74 def __init__(self
, page_set
):
75 super(Facebook
, self
).__init
__(
76 url
='http://www.facebook.com/barackobama',
78 credentials
='facebook',
81 def RunNavigateSteps(self
, action_runner
):
82 super(Facebook
, self
).RunNavigateSteps(action_runner
)
83 action_runner
.WaitForElement(text
='About')
86 class Top10PageSet(page_set_module
.PageSet
):
87 """10 Pages chosen from Alexa top sites"""
90 super(Top10PageSet
, self
).__init
__(
91 archive_data_file
='data/top_10.json',
92 user_agent_type
='desktop',
93 bucket
=page_set_module
.PARTNER_BUCKET
)
95 # top google property; a google tab is often open
96 self
.AddUserStory(Google(self
))
98 # productivity, top google properties
99 # TODO(dominikg): fix crbug.com/386152
100 #self.AddUserStory(Gmail(self))
102 # productivity, top google properties
103 self
.AddUserStory(GoogleCalendar(self
))
106 self
.AddUserStory(Youtube(self
))
108 # top social, Public profile
109 self
.AddUserStory(Facebook(self
))
111 # #6 (Alexa) most visited worldwide,Picked an interesting page
112 self
.AddUserStory(SimplePage('http://en.wikipedia.org/wiki/Wikipedia',
113 self
, name
='Wikipedia'))
115 # #1 world commerce website by visits; #3 commerce in the US by time spent
116 self
.AddUserStory(SimplePage('http://www.amazon.com', self
))
119 self
.AddUserStory(SimplePage('http://www.yahoo.com/', self
))
122 self
.AddUserStory(SimplePage('http://www.bing.com/', self
))
125 self
.AddUserStory(SimplePage('http://www.ask.com/', self
))