forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtop_real_world_desktop.py
479 lines (393 loc) · 16.3 KB
/
top_real_world_desktop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from telemetry.page import shared_page_state
from telemetry.util import wpr_modes
from page_sets.login_helpers import google_login
from page_sets.login_helpers import linkedin_login
from page_sets.rendering import rendering_story
from page_sets.rendering import story_tags
class TopRealWorldDesktopPage(rendering_story.RenderingStory):
ABSTRACT_STORY = True
TAGS = [story_tags.GPU_RASTERIZATION, story_tags.TOP_REAL_WORLD_DESKTOP]
def __init__(self,
page_set,
shared_page_state_class,
name_suffix='',
extra_browser_args=None):
super(TopRealWorldDesktopPage, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunPageInteractions(self, action_runner):
action_runner.Wait(1)
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollPage()
if self.story_set.scroll_forever:
while True:
action_runner.ScrollPage(direction='up')
action_runner.ScrollPage(direction='down')
class GoogleWebSearch2018Page(TopRealWorldDesktopPage):
""" Why: top google property; a google tab is often open """
BASE_NAME = 'google_web_search'
YEAR = '2018'
URL = 'https://www.google.com/#hl=en&q=barack+obama'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(GoogleWebSearch2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(GoogleWebSearch2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(text='Next')
class GoogleImageSearch2018Page(TopRealWorldDesktopPage):
""" Why: tough image case; top google properties """
BASE_NAME = 'google_image_search'
YEAR = '2018'
URL = 'https://www.google.com/search?q=cats&tbm=isch'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(GoogleImageSearch2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(GoogleImageSearch2018Page, self).RunNavigateSteps(action_runner)
class GooglePlus2018Page(TopRealWorldDesktopPage):
""" Why: social; top google property; Public profile; infinite scrolls """
BASE_NAME = 'google_plus'
YEAR = '2018'
URL = 'https://plus.google.com/110031535020051778989/posts'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(GooglePlus2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(GooglePlus2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(text='Posts')
class Youtube2018Page(TopRealWorldDesktopPage):
""" Why: #3 (Alexa global) """
BASE_NAME = 'youtube'
YEAR = '2018'
URL = 'http://www.youtube.com'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Youtube2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(Youtube2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(selector='#buttons')
class Blogspot2018Page(TopRealWorldDesktopPage):
""" Why: #11 (Alexa global), google property; some blogger layouts have
infinite scroll but more interesting """
BASE_NAME = 'blogspot'
YEAR = '2018'
URL = 'http://googlewebmastercentral.blogspot.com/'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Blogspot2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(Blogspot2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement('div[class="searchBox"]')
class Wordpress2018Page(TopRealWorldDesktopPage):
""" Why: #18 (Alexa global), Picked an interesting post """
BASE_NAME = 'wordpress'
YEAR = '2018'
# pylint: disable=line-too-long
URL = 'http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Wordpress2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(Wordpress2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(
# pylint: disable=line-too-long
'a[href="https://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sight/"]'
)
class Facebook2018Page(TopRealWorldDesktopPage):
""" Why: top social,Public profile """
BASE_NAME = 'facebook'
YEAR = '2018'
URL = 'https://www.facebook.com/barackobama'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Facebook2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(Facebook2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(text='Videos')
class Linkedin2018Page(TopRealWorldDesktopPage):
""" Why: #12 (Alexa global), Public profile. """
BASE_NAME = 'linkedin'
YEAR = '2018'
URL = 'http://www.linkedin.com/in/linustorvalds'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Linkedin2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
if self.wpr_mode != wpr_modes.WPR_REPLAY:
linkedin_login.LoginDesktopAccount(action_runner, 'linkedin')
super(Linkedin2018Page, self).RunNavigateSteps(action_runner)
class Wikipedia2018Page(TopRealWorldDesktopPage):
""" Why: #6 (Alexa) most visited worldwide,Picked an interesting page. """
BASE_NAME = 'wikipedia'
YEAR = '2018'
URL = 'http://en.wikipedia.org/wiki/Wikipedia'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Wikipedia2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
class Twitter2018Page(TopRealWorldDesktopPage):
""" Why: #8 (Alexa global),Picked an interesting page """
BASE_NAME = 'twitter'
YEAR = '2018'
URL = 'https://twitter.com/katyperry'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Twitter2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunNavigateSteps(self, action_runner):
super(Twitter2018Page, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement(selector='.ProfileNav')
class Pinterest2018Page(TopRealWorldDesktopPage):
""" Why: #37 (Alexa global) """
BASE_NAME = 'pinterest'
YEAR = '2018'
URL = 'https://www.pinterest.com/search/pins/?q=flowers&rs=typed'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Pinterest2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
class AccuWeather2018Page(TopRealWorldDesktopPage):
""" Why: #2 weather according to Alexa """
BASE_NAME = 'accu_weather'
YEAR = '2018'
URL = 'https://www.accuweather.com/en/us/new-york-ny/10017/weather-forecast/349727'
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(AccuWeather2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
class Twitch2018Page(TopRealWorldDesktopPage):
""" Why: #1 games according to Alexa """
BASE_NAME = 'twitch'
YEAR = '2018'
URL = 'https://www.twitch.tv'
TAGS = TopRealWorldDesktopPage.TAGS + [
story_tags.REPRESENTATIVE_MAC_DESKTOP
]
def __init__(self,
page_set,
shared_page_state_class=shared_page_state.SharedPageState,
name_suffix='',
extra_browser_args=None):
super(Twitch2018Page, self).__init__(
page_set=page_set,
shared_page_state_class=shared_page_state_class,
name_suffix=name_suffix,
extra_browser_args=extra_browser_args)
def RunPageInteractions(self, action_runner):
action_runner.WaitForElement(selector='#mantle_skin')
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollPageToElement(selector='.footer')
if self.story_set.scroll_forever:
while True:
action_runner.ScrollPage(direction='up')
action_runner.ScrollPage(direction='down')
class Gmail2018SmoothPage(TopRealWorldDesktopPage):
""" Why: productivity, top google properties """
BASE_NAME = 'gmail'
YEAR = '2018'
URL = 'https://mail.google.com/mail/'
def RunNavigateSteps(self, action_runner):
if self.wpr_mode != wpr_modes.WPR_REPLAY:
google_login.NewLoginGoogleAccount(action_runner, 'googletest')
super(Gmail2018SmoothPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForJavaScriptCondition(
'window.gmonkey !== undefined &&'
'document.getElementById("gb") !== null &&'
'document.readyState == "complete"')
def RunPageInteractions(self, action_runner):
action_runner.WaitForElement(selector='.Tm.aeJ')
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollElement(selector='.Tm.aeJ')
if self.story_set.scroll_forever:
while True:
action_runner.ScrollElement(
direction='up', selector='.Tm.aeJ')
action_runner.ScrollElement(
direction='down', selector='.Tm.aeJ')
class GoogleCalendar2018SmoothPage(TopRealWorldDesktopPage):
""" Why: productivity, top google properties """
BASE_NAME='google_calendar'
YEAR = '2018'
URL='https://www.google.com/calendar/'
def RunNavigateSteps(self, action_runner):
if self.wpr_mode != wpr_modes.WPR_REPLAY:
google_login.NewLoginGoogleAccount(action_runner, 'googletest')
super(GoogleCalendar2018SmoothPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForElement('span[class~="sm8sCf"]')
action_runner.ExecuteJavaScript("""
(function() {
var elem = document.createElement('meta');
elem.name='viewport';
elem.content='initial-scale=1';
document.body.appendChild(elem);
})();""")
action_runner.Wait(1)
def RunPageInteractions(self, action_runner):
action_runner.WaitForElement('span[class~="sm8sCf"]')
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollElement(selector='#YPCqFe')
if self.story_set.scroll_forever:
while True:
action_runner.ScrollElement(
direction='up', selector='#YPCqFe')
action_runner.ScrollElement(
direction='down', selector='#YPCqFe')
class GoogleDoc2018SmoothPage(TopRealWorldDesktopPage):
""" Why: productivity, top google properties; Sample doc in the link """
# pylint: disable=line-too-long
URL = 'https://docs.google.com/document/d/1X-IKNjtEnx-WW5JIKRLsyhz5sbsat3mfTpAPUSX3_s4/view'
BASE_NAME='google_docs'
YEAR = '2018'
def RunNavigateSteps(self, action_runner):
super(GoogleDoc2018SmoothPage, self).RunNavigateSteps(action_runner)
action_runner.WaitForJavaScriptCondition(
'document.getElementsByClassName("kix-appview-editor").length')
def RunPageInteractions(self, action_runner):
action_runner.WaitForElement(selector='#printButton')
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollElement(selector='.kix-appview-editor')
if self.story_set.scroll_forever:
while True:
action_runner.ScrollElement(
direction='up', selector='.kix-appview-editor')
action_runner.ScrollElement(
direction='down', selector='.kix-appview-editor')
class ESPN2018SmoothPage(TopRealWorldDesktopPage):
""" Why: #1 sports """
BASE_NAME='espn'
YEAR = '2018'
URL = 'http://espn.go.com'
def RunPageInteractions(self, action_runner):
action_runner.WaitForElement(selector='#global-scoreboard')
with action_runner.CreateGestureInteraction('ScrollAction'):
action_runner.ScrollPage(left_start_ratio=0.1)
if self.story_set.scroll_forever:
while True:
action_runner.ScrollPage(direction='up', left_start_ratio=0.1)
action_runner.ScrollPage(direction='down', left_start_ratio=0.1)
class YahooNews2018Page(TopRealWorldDesktopPage):
"""Why: #1 news worldwide (Alexa global)"""
BASE_NAME = 'yahoo_news'
YEAR = '2018'
URL = 'http://news.yahoo.com'
class CNNNews2018Page(TopRealWorldDesktopPage):
"""Why: #2 news worldwide"""
BASE_NAME = 'cnn'
YEAR = '2018'
URL = 'http://www.cnn.com'
class Amazon2018Page(TopRealWorldDesktopPage):
# Why: #1 world commerce website by visits; #3 commerce in the US by
# time spent
BASE_NAME = 'amazon'
YEAR = '2018'
URL = 'http://www.amazon.com'
class Ebay2018Page(TopRealWorldDesktopPage):
# Why: #1 commerce website by time spent by users in US
BASE_NAME = 'ebay'
YEAR = '2018'
URL = 'http://www.ebay.com'
class Booking2018Page(TopRealWorldDesktopPage):
# Why: #1 Alexa recreation
BASE_NAME = 'booking.com'
YEAR = '2018'
URL = 'http://booking.com'
class YahooAnswers2018Page(TopRealWorldDesktopPage):
# Why: #1 Alexa reference
BASE_NAME = 'yahoo_answers'
YEAR = '2018'
URL = 'http://answers.yahoo.com'
class YahooSports2018Page(TopRealWorldDesktopPage):
# Why: #1 Alexa sports
BASE_NAME = 'yahoo_sports'
YEAR = '2018'
URL = 'http://sports.yahoo.com/'
class TechCrunch2018Page(TopRealWorldDesktopPage):
# Why: top tech blog
BASE_NAME = 'techcrunch'
YEAR = '2018'
URL = 'http://techcrunch.com'