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