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 KeyMobileSitesPage(page_module
.Page
):
10 def __init__(self
, url
, page_set
, name
='', labels
=None):
11 super(KeyMobileSitesPage
, self
).__init
__(
12 url
=url
, page_set
=page_set
, name
=name
,
13 shared_page_state_class
=shared_page_state
.SharedMobilePageState
,
14 credentials_path
='data/credentials.json', labels
=labels
)
15 self
.archive_data_file
= 'data/key_mobile_sites.json'
18 class CapitolVolkswagenPage(KeyMobileSitesPage
):
20 """ Why: Typical mobile business site """
22 def __init__(self
, page_set
):
23 super(CapitolVolkswagenPage
, self
).__init
__(
24 url
=('http://iphone.capitolvolkswagen.com/index.htm'
25 '#new-inventory_p_2Fsb-new_p_2Ehtm_p_3Freset_p_3DInventoryListing'),
28 def RunNavigateSteps(self
, action_runner
):
29 super(CapitolVolkswagenPage
, self
).RunNavigateSteps(action_runner
)
30 action_runner
.WaitForElement(text
='Next 35')
31 action_runner
.WaitForJavaScriptCondition(
32 'document.body.scrollHeight > 2560')
36 class TheVergeArticlePage(KeyMobileSitesPage
):
38 """ Why: Top tech blog """
40 def __init__(self
, page_set
):
41 super(TheVergeArticlePage
, self
).__init
__(
42 # pylint: disable=C0301
43 url
='http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy',
46 def RunNavigateSteps(self
, action_runner
):
47 super(TheVergeArticlePage
, self
).RunNavigateSteps(action_runner
)
48 action_runner
.WaitForJavaScriptCondition(
49 'window.Chorus !== undefined &&'
50 'window.Chorus.Comments !== undefined &&'
51 'window.Chorus.Comments.Json !== undefined &&'
52 '(window.Chorus.Comments.loaded ||'
53 ' window.Chorus.Comments.Json.load_comments())')
56 class CnnArticlePage(KeyMobileSitesPage
):
58 """ Why: Top news site """
60 def __init__(self
, page_set
):
61 super(CnnArticlePage
, self
).__init
__(
62 # pylint: disable=C0301
63 url
='http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html',
66 def RunNavigateSteps(self
, action_runner
):
67 super(CnnArticlePage
, self
).RunNavigateSteps(action_runner
)
72 class FacebookPage(KeyMobileSitesPage
):
74 """ Why: #1 (Alexa global) """
76 def __init__(self
, page_set
):
77 super(FacebookPage
, self
).__init
__(
78 url
='https://facebook.com/barackobama',
81 def RunNavigateSteps(self
, action_runner
):
82 super(FacebookPage
, self
).RunNavigateSteps(action_runner
)
83 action_runner
.WaitForJavaScriptCondition(
84 'document.getElementById("u_0_c") !== null &&'
85 'document.body.scrollHeight > window.innerHeight')
88 class YoutubeMobilePage(KeyMobileSitesPage
):
90 """ Why: #3 (Alexa global) """
92 def __init__(self
, page_set
):
93 super(YoutubeMobilePage
, self
).__init
__(
94 url
='http://m.youtube.com/watch?v=9hBpF_Zj4OA',
97 def RunNavigateSteps(self
, action_runner
):
98 super(YoutubeMobilePage
, self
).RunNavigateSteps(action_runner
)
99 action_runner
.WaitForJavaScriptCondition(
100 'document.getElementById("paginatortarget") !== null')
103 class LinkedInPage(KeyMobileSitesPage
):
105 """ Why: #12 (Alexa global),Public profile """
107 def __init__(self
, page_set
):
108 super(LinkedInPage
, self
).__init
__(
109 url
='https://www.linkedin.com/in/linustorvalds',
113 def RunNavigateSteps(self
, action_runner
):
114 super(LinkedInPage
, self
).RunNavigateSteps(action_runner
)
115 action_runner
.WaitForJavaScriptCondition(
116 'document.getElementById("profile-view-scroller") !== null')
120 class YahooAnswersPage(KeyMobileSitesPage
):
122 """ Why: #1 Alexa reference """
124 def __init__(self
, page_set
):
125 super(YahooAnswersPage
, self
).__init
__(
126 # pylint: disable=C0301
127 url
='http://answers.yahoo.com/question/index?qid=20110117024343AAopj8f',
130 def RunNavigateSteps(self
, action_runner
):
131 super(YahooAnswersPage
, self
).RunNavigateSteps(action_runner
)
132 action_runner
.WaitForElement(text
='Other Answers (1 - 20 of 149)')
133 action_runner
.ClickElement(text
='Other Answers (1 - 20 of 149)')
136 class GmailPage(KeyMobileSitesPage
):
138 """ Why: productivity, top google properties """
140 def __init__(self
, page_set
):
141 super(GmailPage
, self
).__init
__(
142 url
='https://mail.google.com/mail/',
145 self
.credentials
= 'google'
147 def RunNavigateSteps(self
, action_runner
):
148 super(GmailPage
, self
).RunNavigateSteps(action_runner
)
149 action_runner
.WaitForJavaScriptCondition(
150 'document.getElementById("og_user_warning") !== null')
151 action_runner
.WaitForJavaScriptCondition(
152 'document.getElementById("og_user_warning") === null')
155 class GroupClonedPage(KeyMobileSitesPage
):
157 """ Why: crbug.com/172906 """
159 def __init__(self
, page_set
):
160 super(GroupClonedPage
, self
).__init
__(
161 url
='http://groupcloned.com',
165 def RunNavigateSteps(self
, action_runner
):
166 super(GroupClonedPage
, self
).RunNavigateSteps(action_runner
)
167 action_runner
.Wait(5)
168 action_runner
.WaitForJavaScriptCondition('''
169 document.getElementById("element-19") !== null &&
170 document.getElementById("element-19").contentDocument
171 .getElementById("element-22") !== null &&
172 document.getElementById("element-19").contentDocument
173 .getElementsByClassName(
174 "container list-item gc-list-item stretched").length !== 0''')
177 class GroupClonedListImagesPage(KeyMobileSitesPage
):
179 """ Why: crbug.com/172906 """
181 def __init__(self
, page_set
):
182 super(GroupClonedListImagesPage
, self
).__init
__(
183 url
='http://groupcloned.com/test/list-images-variable/index.html',
186 def RunNavigateSteps(self
, action_runner
):
187 super(GroupClonedListImagesPage
, self
).RunNavigateSteps(action_runner
)
188 action_runner
.WaitForJavaScriptCondition(
189 'document.getElementById("element-5") !== null')
192 class GoogleNewsMobilePage(KeyMobileSitesPage
):
194 """ Why: Google News: accelerated scrolling version """
196 def __init__(self
, page_set
):
197 super(GoogleNewsMobilePage
, self
).__init
__(
198 url
='http://mobile-news.sandbox.google.com/news/pt1',
201 def RunNavigateSteps(self
, action_runner
):
202 super(GoogleNewsMobilePage
, self
).RunNavigateSteps(action_runner
)
203 action_runner
.WaitForJavaScriptCondition(
204 'typeof NEWS_telemetryReady !== "undefined" && '
205 'NEWS_telemetryReady == true')
208 class GoogleNewsMobile2Page(KeyMobileSitesPage
):
211 Why: Google News: this iOS version is slower than accelerated scrolling
214 def __init__(self
, page_set
):
215 super(GoogleNewsMobile2Page
, self
).__init
__(
216 url
='http://mobile-news.sandbox.google.com/news/pt0',
219 def RunNavigateSteps(self
, action_runner
):
220 super(GoogleNewsMobile2Page
, self
).RunNavigateSteps(action_runner
)
221 action_runner
.WaitForJavaScriptCondition(
222 'document.getElementById(":h") != null')
223 action_runner
.Wait(1)
226 class AmazonNicolasCagePage(KeyMobileSitesPage
):
229 Why: #1 world commerce website by visits; #3 commerce in the US by time spent
232 def __init__(self
, page_set
):
233 super(AmazonNicolasCagePage
, self
).__init
__(
234 url
='http://www.amazon.com/gp/aw/s/ref=is_box_?k=nicolas+cage',