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
8 class TopPages(page_module
.Page
):
10 def __init__(self
, url
, page_set
, shared_page_state_class
,
11 name
='', credentials
=None):
12 super(TopPages
, self
).__init
__(
13 url
=url
, page_set
=page_set
, name
=name
,
14 credentials_path
='data/credentials.json',
15 shared_page_state_class
=shared_page_state_class
)
16 self
.archive_data_file
= 'data/top_25.json'
17 self
.credentials
= credentials
20 class GoogleWebSearchPage(TopPages
):
22 """ Why: top google property; a google tab is often open """
24 def __init__(self
, page_set
,
25 shared_page_state_class
=shared_page_state
.SharedPageState
):
26 super(GoogleWebSearchPage
, self
).__init
__(
27 url
='https://www.google.com/#hl=en&q=barack+obama',
29 shared_page_state_class
=shared_page_state_class
)
31 def RunNavigateSteps(self
, action_runner
):
32 super(GoogleWebSearchPage
, self
).RunNavigateSteps(action_runner
)
33 action_runner
.WaitForElement(text
='Next')
36 class GoogleImageSearchPage(TopPages
):
38 """ Why: tough image case; top google properties """
40 def __init__(self
, page_set
,
41 shared_page_state_class
=shared_page_state
.SharedPageState
):
42 super(GoogleImageSearchPage
, self
).__init
__(
43 'https://www.google.com/search?q=cats&tbm=isch',
44 page_set
=page_set
, credentials
='google',
45 shared_page_state_class
=shared_page_state_class
)
48 class GmailPage(TopPages
):
50 """ Why: productivity, top google properties """
52 def __init__(self
, page_set
,
53 shared_page_state_class
=shared_page_state
.SharedPageState
):
54 super(GmailPage
, self
).__init
__(
55 url
='https://mail.google.com/mail/',
58 shared_page_state_class
=shared_page_state_class
)
60 def RunNavigateSteps(self
, action_runner
):
61 super(GmailPage
, self
).RunNavigateSteps(action_runner
)
62 action_runner
.WaitForJavaScriptCondition(
63 'window.gmonkey !== undefined &&'
64 'document.getElementById("gb") !== null')
67 class GoogleCalendarPage(TopPages
):
69 """ Why: productivity, top google properties """
71 def __init__(self
, page_set
,
72 shared_page_state_class
=shared_page_state
.SharedPageState
):
73 super(GoogleCalendarPage
, self
).__init
__(
74 url
='https://www.google.com/calendar/',
77 shared_page_state_class
=shared_page_state_class
)
79 def RunNavigateSteps(self
, action_runner
):
80 super(GoogleCalendarPage
, self
).RunNavigateSteps(action_runner
)
82 action_runner
.WaitForElement('div[class~="navForward"]')
83 action_runner
.ExecuteJavaScript('''
85 var elem = document.createElement('meta');
87 elem.content='initial-scale=1';
88 document.body.appendChild(elem);
93 class GoogleDocPage(TopPages
):
95 """ Why: productivity, top google properties; Sample doc in the link """
97 def __init__(self
, page_set
,
98 shared_page_state_class
=shared_page_state
.SharedPageState
):
99 super(GoogleDocPage
, self
).__init
__(
100 # pylint: disable=C0301
101 url
='https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfTpAPUSX3_s4/view',
103 name
='Docs (1 open document tab)',
104 credentials
='google',
105 shared_page_state_class
=shared_page_state_class
)
107 def RunNavigateSteps(self
, action_runner
):
108 super(GoogleDocPage
, self
).RunNavigateSteps(action_runner
)
109 action_runner
.Wait(2)
110 action_runner
.WaitForJavaScriptCondition(
111 'document.getElementsByClassName("kix-appview-editor").length')
114 class GooglePlusPage(TopPages
):
116 """ Why: social; top google property; Public profile; infinite scrolls """
118 def __init__(self
, page_set
,
119 shared_page_state_class
=shared_page_state
.SharedPageState
):
120 super(GooglePlusPage
, self
).__init
__(
121 url
='https://plus.google.com/110031535020051778989/posts',
123 credentials
='google',
124 shared_page_state_class
=shared_page_state_class
)
126 def RunNavigateSteps(self
, action_runner
):
127 super(GooglePlusPage
, self
).RunNavigateSteps(action_runner
)
128 action_runner
.WaitForElement(text
='Home')
131 class YoutubePage(TopPages
):
133 """ Why: #3 (Alexa global) """
135 def __init__(self
, page_set
,
136 shared_page_state_class
=shared_page_state
.SharedPageState
):
137 super(YoutubePage
, self
).__init
__(
138 url
='http://www.youtube.com',
139 page_set
=page_set
, credentials
='google',
140 shared_page_state_class
=shared_page_state_class
)
142 def RunNavigateSteps(self
, action_runner
):
143 super(YoutubePage
, self
).RunNavigateSteps(action_runner
)
144 action_runner
.Wait(2)
147 class BlogspotPage(TopPages
):
149 """ Why: #11 (Alexa global), google property; some blogger layouts have
150 infinite scroll but more interesting """
152 def __init__(self
, page_set
,
153 shared_page_state_class
=shared_page_state
.SharedPageState
):
154 super(BlogspotPage
, self
).__init
__(
155 url
='http://googlewebmastercentral.blogspot.com/',
158 shared_page_state_class
=shared_page_state_class
)
160 def RunNavigateSteps(self
, action_runner
):
161 super(BlogspotPage
, self
).RunNavigateSteps(action_runner
)
162 action_runner
.WaitForElement(text
='accessibility')
165 class WordpressPage(TopPages
):
167 """ Why: #18 (Alexa global), Picked an interesting post """
169 def __init__(self
, page_set
,
170 shared_page_state_class
=shared_page_state
.SharedPageState
):
171 super(WordpressPage
, self
).__init
__(
172 # pylint: disable=C0301
173 url
='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
176 shared_page_state_class
=shared_page_state_class
)
178 def RunNavigateSteps(self
, action_runner
):
179 super(WordpressPage
, self
).RunNavigateSteps(action_runner
)
180 action_runner
.WaitForElement(
181 # pylint: disable=C0301
182 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
185 class FacebookPage(TopPages
):
187 """ Why: top social,Public profile """
189 def __init__(self
, page_set
,
190 shared_page_state_class
=shared_page_state
.SharedPageState
):
191 super(FacebookPage
, self
).__init
__(
192 url
='https://www.facebook.com/barackobama',
194 name
='Facebook', credentials
='facebook2',
195 shared_page_state_class
=shared_page_state_class
)
197 def RunNavigateSteps(self
, action_runner
):
198 super(FacebookPage
, self
).RunNavigateSteps(action_runner
)
199 action_runner
.WaitForElement(text
='Chat')
202 class LinkedinPage(TopPages
):
204 """ Why: #12 (Alexa global), Public profile. """
206 def __init__(self
, page_set
,
207 shared_page_state_class
=shared_page_state
.SharedPageState
):
208 super(LinkedinPage
, self
).__init
__(
209 url
='http://www.linkedin.com/in/linustorvalds', page_set
=page_set
,
211 shared_page_state_class
=shared_page_state_class
)
214 class WikipediaPage(TopPages
):
216 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page. """
218 def __init__(self
, page_set
,
219 shared_page_state_class
=shared_page_state
.SharedPageState
):
220 super(WikipediaPage
, self
).__init
__(
221 url
='http://en.wikipedia.org/wiki/Wikipedia', page_set
=page_set
,
222 name
='Wikipedia (1 tab)',
223 shared_page_state_class
=shared_page_state_class
)
226 class TwitterPage(TopPages
):
228 """ Why: #8 (Alexa global),Picked an interesting page """
230 def __init__(self
, page_set
,
231 shared_page_state_class
=shared_page_state
.SharedPageState
):
232 super(TwitterPage
, self
).__init
__(
233 url
='https://twitter.com/katyperry',
236 shared_page_state_class
=shared_page_state_class
)
238 def RunNavigateSteps(self
, action_runner
):
239 super(TwitterPage
, self
).RunNavigateSteps(action_runner
)
240 action_runner
.Wait(2)
243 class PinterestPage(TopPages
):
245 """ Why: #37 (Alexa global) """
247 def __init__(self
, page_set
,
248 shared_page_state_class
=shared_page_state
.SharedPageState
):
249 super(PinterestPage
, self
).__init
__(
250 url
='http://pinterest.com',
252 shared_page_state_class
=shared_page_state_class
,
256 class ESPNPage(TopPages
):
258 """ Why: #1 sports """
260 def __init__(self
, page_set
,
261 shared_page_state_class
=shared_page_state
.SharedPageState
):
262 super(ESPNPage
, self
).__init
__(
263 url
='http://espn.go.com',
265 shared_page_state_class
=shared_page_state_class
,
269 class WeatherPage(TopPages
):
271 """ Why: #7 (Alexa news); #27 total time spent, picked interesting page. """
273 def __init__(self
, page_set
,
274 shared_page_state_class
=shared_page_state
.SharedPageState
):
275 super(WeatherPage
, self
).__init
__(
276 url
='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
278 shared_page_state_class
=shared_page_state_class
,
282 class YahooGamesPage(TopPages
):
284 """ Why: #1 games according to Alexa (with actual games in it) """
286 def __init__(self
, page_set
,
287 shared_page_state_class
=shared_page_state
.SharedPageState
):
288 super(YahooGamesPage
, self
).__init
__(
289 url
='http://games.yahoo.com',
291 shared_page_state_class
=shared_page_state_class
)
293 def RunNavigateSteps(self
, action_runner
):
294 super(YahooGamesPage
, self
).RunNavigateSteps(action_runner
)
295 action_runner
.Wait(2)