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
7 class TopPages(page_module
.Page
):
9 def __init__(self
, url
, page_set
, name
='', credentials
=None):
10 super(TopPages
, self
).__init
__(
11 url
=url
, page_set
=page_set
, name
=name
,
12 credentials_path
='data/credentials.json')
13 self
.user_agent_type
= 'desktop'
14 self
.archive_data_file
= 'data/top_25.json'
15 self
.credentials
= credentials
18 class GoogleWebSearchPage(TopPages
):
20 """ Why: top google property; a google tab is often open """
22 def __init__(self
, page_set
):
23 super(GoogleWebSearchPage
, self
).__init
__(
24 url
='https://www.google.com/#hl=en&q=barack+obama',
27 def RunNavigateSteps(self
, action_runner
):
28 action_runner
.NavigateToPage(self
)
29 action_runner
.WaitForElement(text
='Next')
32 class GoogleImageSearchPage(TopPages
):
34 """ Why: tough image case; top google properties """
36 def __init__(self
, page_set
):
37 super(GoogleImageSearchPage
, self
).__init
__(
38 'https://www.google.com/search?q=cats&tbm=isch',
39 page_set
=page_set
, credentials
='google')
42 class GmailPage(TopPages
):
44 """ Why: productivity, top google properties """
46 def __init__(self
, page_set
):
47 super(GmailPage
, self
).__init
__(
48 url
='https://mail.google.com/mail/',
52 def RunNavigateSteps(self
, action_runner
):
53 action_runner
.NavigateToPage(self
)
54 action_runner
.WaitForJavaScriptCondition(
55 'window.gmonkey !== undefined &&'
56 'document.getElementById("gb") !== null')
59 class GoogleCalendarPage(TopPages
):
61 """ Why: productivity, top google properties """
63 def __init__(self
, page_set
):
64 super(GoogleCalendarPage
, self
).__init
__(
65 url
='https://www.google.com/calendar/',
69 def RunNavigateSteps(self
, action_runner
):
70 action_runner
.NavigateToPage(self
)
72 action_runner
.WaitForElement('div[class~="navForward"]')
73 action_runner
.ExecuteJavaScript('''
75 var elem = document.createElement('meta');
77 elem.content='initial-scale=1';
78 document.body.appendChild(elem);
83 class GoogleDocPage(TopPages
):
85 """ Why: productivity, top google properties; Sample doc in the link """
87 def __init__(self
, page_set
):
88 super(GoogleDocPage
, self
).__init
__(
89 # pylint: disable=C0301
90 url
='https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfTpAPUSX3_s4/view',
92 name
='Docs (1 open document tab)',
95 def RunNavigateSteps(self
, action_runner
):
96 action_runner
.NavigateToPage(self
)
98 action_runner
.WaitForJavaScriptCondition(
99 'document.getElementsByClassName("kix-appview-editor").length')
102 class GooglePlusPage(TopPages
):
104 """ Why: social; top google property; Public profile; infinite scrolls """
106 def __init__(self
, page_set
):
107 super(GooglePlusPage
, self
).__init
__(
108 url
='https://plus.google.com/110031535020051778989/posts',
110 credentials
='google')
112 def RunNavigateSteps(self
, action_runner
):
113 action_runner
.NavigateToPage(self
)
114 action_runner
.WaitForElement(text
='Home')
117 class YoutubePage(TopPages
):
119 """ Why: #3 (Alexa global) """
121 def __init__(self
, page_set
):
122 super(YoutubePage
, self
).__init
__(
123 url
='http://www.youtube.com',
124 page_set
=page_set
, credentials
='google')
126 def RunNavigateSteps(self
, action_runner
):
127 action_runner
.NavigateToPage(self
)
128 action_runner
.Wait(2)
131 class BlogspotPage(TopPages
):
133 """ Why: #11 (Alexa global), google property; some blogger layouts have
134 infinite scroll but more interesting """
136 def __init__(self
, page_set
):
137 super(BlogspotPage
, self
).__init
__(
138 url
='http://googlewebmastercentral.blogspot.com/',
142 def RunNavigateSteps(self
, action_runner
):
143 action_runner
.NavigateToPage(self
)
144 action_runner
.WaitForElement(text
='accessibility')
147 class WordpressPage(TopPages
):
149 """ Why: #18 (Alexa global), Picked an interesting post """
151 def __init__(self
, page_set
):
152 super(WordpressPage
, self
).__init
__(
153 # pylint: disable=C0301
154 url
='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
158 def RunNavigateSteps(self
, action_runner
):
159 action_runner
.NavigateToPage(self
)
160 action_runner
.WaitForElement(
161 # pylint: disable=C0301
162 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]')
165 class FacebookPage(TopPages
):
167 """ Why: top social,Public profile """
169 def __init__(self
, page_set
):
170 super(FacebookPage
, self
).__init
__(
171 url
='https://www.facebook.com/barackobama',
173 name
='Facebook', credentials
='facebook2')
175 def RunNavigateSteps(self
, action_runner
):
176 action_runner
.NavigateToPage(self
)
177 action_runner
.WaitForElement(text
='Chat')
180 class LinkedinPage(TopPages
):
182 """ Why: #12 (Alexa global), Public profile. """
184 def __init__(self
, page_set
):
185 super(LinkedinPage
, self
).__init
__(
186 url
='http://www.linkedin.com/in/linustorvalds', page_set
=page_set
,
190 class WikipediaPage(TopPages
):
192 """ Why: #6 (Alexa) most visited worldwide,Picked an interesting page. """
194 def __init__(self
, page_set
):
195 super(WikipediaPage
, self
).__init
__(
196 url
='http://en.wikipedia.org/wiki/Wikipedia', page_set
=page_set
,
197 name
='Wikipedia (1 tab)')
200 class TwitterPage(TopPages
):
202 """ Why: #8 (Alexa global),Picked an interesting page """
204 def __init__(self
, page_set
):
205 super(TwitterPage
, self
).__init
__(
206 url
='https://twitter.com/katyperry',
210 def RunNavigateSteps(self
, action_runner
):
211 action_runner
.NavigateToPage(self
)
212 action_runner
.Wait(2)
215 class PinterestPage(TopPages
):
217 """ Why: #37 (Alexa global) """
219 def __init__(self
, page_set
):
220 super(PinterestPage
, self
).__init
__(
221 url
='http://pinterest.com',
226 class ESPNPage(TopPages
):
228 """ Why: #1 sports """
230 def __init__(self
, page_set
):
231 super(ESPNPage
, self
).__init
__(
232 url
='http://espn.go.com',
237 class WeatherPage(TopPages
):
239 """ Why: #7 (Alexa news); #27 total time spent, picked interesting page. """
241 def __init__(self
, page_set
):
242 super(WeatherPage
, self
).__init
__(
243 url
='http://www.weather.com/weather/right-now/Mountain+View+CA+94043',
248 class YahooGamesPage(TopPages
):
250 """ Why: #1 games according to Alexa (with actual games in it) """
252 def __init__(self
, page_set
):
253 super(YahooGamesPage
, self
).__init
__(
254 url
='http://games.yahoo.com',
257 def RunNavigateSteps(self
, action_runner
):
258 action_runner
.NavigateToPage(self
)
259 action_runner
.Wait(2)