Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: tools/perf/page_sets/system_health/browsing_stories.py

Issue 2414153004: [System Health] Make pinterest/tumblr stories scroll to elements off screen. (Closed)
Patch Set: tumblr wpr Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from page_sets.system_health import platforms 5 from page_sets.system_health import platforms
6 from page_sets.system_health import system_health_story 6 from page_sets.system_health import system_health_story
7 7
8 from page_sets.login_helpers import pinterest_login 8 from page_sets.login_helpers import pinterest_login
9 9
10 from telemetry import decorators 10 from telemetry import decorators
(...skipping 11 matching lines...) Expand all
22 ITEM_SELECTOR = NotImplemented 22 ITEM_SELECTOR = NotImplemented
23 ABSTRACT_STORY = True 23 ABSTRACT_STORY = True
24 24
25 def _WaitForNavigation(self, action_runner): 25 def _WaitForNavigation(self, action_runner):
26 if not self.IS_SINGLE_PAGE_APP: 26 if not self.IS_SINGLE_PAGE_APP:
27 action_runner.WaitForNavigate() 27 action_runner.WaitForNavigate()
28 28
29 def _NavigateToItem(self, action_runner, index): 29 def _NavigateToItem(self, action_runner, index):
30 item_selector = 'document.querySelectorAll("%s")[%d]' % ( 30 item_selector = 'document.querySelectorAll("%s")[%d]' % (
31 self.ITEM_SELECTOR, index) 31 self.ITEM_SELECTOR, index)
32 # Only scrolls if element is not currently in viewport.
33 action_runner.ScrollPageToElement(element_function=item_selector)
32 self._ClickLink(action_runner, item_selector) 34 self._ClickLink(action_runner, item_selector)
33 35
34 def _ClickLink(self, action_runner, element_function): 36 def _ClickLink(self, action_runner, element_function):
35 action_runner.WaitForElement(element_function=element_function) 37 action_runner.WaitForElement(element_function=element_function)
36 action_runner.ClickElement(element_function=element_function) 38 action_runner.ClickElement(element_function=element_function)
37 self._WaitForNavigation(action_runner) 39 self._WaitForNavigation(action_runner)
38 40
39 def _NavigateBack(self, action_runner): 41 def _NavigateBack(self, action_runner):
40 action_runner.ExecuteJavaScript('window.history.back()') 42 action_runner.ExecuteJavaScript('window.history.back()')
41 self._WaitForNavigation(action_runner) 43 self._WaitForNavigation(action_runner)
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 # theater viewer. 310 # theater viewer.
309 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS 311 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS
310 IS_SINGLE_PAGE_APP = True 312 IS_SINGLE_PAGE_APP = True
311 313
312 314
313 class TumblrDesktopStory(_MediaBrowsingStory): 315 class TumblrDesktopStory(_MediaBrowsingStory):
314 NAME = 'browse:media:tumblr' 316 NAME = 'browse:media:tumblr'
315 URL = 'https://tumblr.com/search/gifs' 317 URL = 'https://tumblr.com/search/gifs'
316 ITEM_SELECTOR = '.photo' 318 ITEM_SELECTOR = '.photo'
317 IS_SINGLE_PAGE_APP = True 319 IS_SINGLE_PAGE_APP = True
318 ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented. 320 ITEMS_TO_VISIT = 8
319 ITEM_VIEW_TIME_IN_SECONDS = 5
320 INCREMENT_INDEX_AFTER_EACH_ITEM = True 321 INCREMENT_INDEX_AFTER_EACH_ITEM = True
321 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909. 322 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
322 323
323 def _ViewMediaItem(self, action_runner, index): 324 def _ViewMediaItem(self, action_runner, index):
324 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index) 325 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index)
325 action_runner.MouseClick(selector='#tumblr_lightbox_center_image') 326 action_runner.MouseClick(selector='#tumblr_lightbox_center_image')
326 327 action_runner.Wait(1) # To make browsing more realistic.
327 328
328 class PinterestDesktopStory(_MediaBrowsingStory): 329 class PinterestDesktopStory(_MediaBrowsingStory):
329 NAME = 'browse:media:pinterest' 330 NAME = 'browse:media:pinterest'
330 URL = 'https://pinterest.com' 331 URL = 'https://pinterest.com'
331 ITEM_SELECTOR = '.pinImageDim' 332 ITEM_SELECTOR = '.pinImageDim'
332 IS_SINGLE_PAGE_APP = True 333 IS_SINGLE_PAGE_APP = True
333 ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented. 334 ITEMS_TO_VISIT = 8
334 ITEM_VIEW_TIME_IN_SECONDS = 5
335 INCREMENT_INDEX_AFTER_EACH_ITEM = True 335 INCREMENT_INDEX_AFTER_EACH_ITEM = True
336 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 336 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
337 337
338 def _Login(self, action_runner): 338 def _Login(self, action_runner):
339 pinterest_login.LoginDesktopAccount(action_runner, 'googletest', 339 pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
340 self.credentials_path) 340 self.credentials_path)
341 341
342 def _ViewMediaItem(self, action_runner, index): 342 def _ViewMediaItem(self, action_runner, index):
343 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index) 343 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index)
344 # To imitate real user interaction, we do not want to pin every post. 344 # To imitate real user interaction, we do not want to pin every post.
(...skipping 10 matching lines...) Expand all
355 inner_save_function = 'document.querySelector(".nameAndIcons")' 355 inner_save_function = 'document.querySelector(".nameAndIcons")'
356 action_runner.WaitForElement(element_function=inner_save_function) 356 action_runner.WaitForElement(element_function=inner_save_function)
357 action_runner.ClickElement(element_function=inner_save_function) 357 action_runner.ClickElement(element_function=inner_save_function)
358 action_runner.Wait(1) # Wait to make navigation realistic. 358 action_runner.Wait(1) # Wait to make navigation realistic.
359 359
360 # Close selection. 360 # Close selection.
361 x_element_function = ('document.querySelector(' 361 x_element_function = ('document.querySelector('
362 '".Button.borderless.close.visible")') 362 '".Button.borderless.close.visible")')
363 action_runner.ClickElement(element_function=x_element_function) 363 action_runner.ClickElement(element_function=x_element_function)
364 action_runner.Wait(1) # Wait to make navigation realistic. 364 action_runner.Wait(1) # Wait to make navigation realistic.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698