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

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: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
rnephew (Reviews Here) 2016/10/14 22:52:52 Should I just use the default 15 here?
petrcermak 2016/10/17 08:51:37 Unless it makes the story too long or less stable,
rnephew (Reviews Here) 2016/10/17 18:48:19 After some local experimenting it does seem to mak
319 ITEM_VIEW_TIME_IN_SECONDS = 5 321 ITEM_VIEW_TIME_IN_SECONDS = 5
320 INCREMENT_INDEX_AFTER_EACH_ITEM = True 322 INCREMENT_INDEX_AFTER_EACH_ITEM = True
321 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909. 323 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
322 324
323 def _ViewMediaItem(self, action_runner, index): 325 def _ViewMediaItem(self, action_runner, index):
324 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index) 326 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index)
325 action_runner.MouseClick(selector='#tumblr_lightbox_center_image') 327 action_runner.MouseClick(selector='#tumblr_lightbox_center_image')
326 328 action_runner.Wait(1) # To make browsing more realistic.
petrcermak 2016/10/17 08:51:37 nit: There should be two spaces before a comment.
rnephew (Reviews Here) 2016/10/17 18:48:19 Done.
327 329
328 class PinterestDesktopStory(_MediaBrowsingStory): 330 class PinterestDesktopStory(_MediaBrowsingStory):
329 NAME = 'browse:media:pinterest' 331 NAME = 'browse:media:pinterest'
330 URL = 'https://pinterest.com' 332 URL = 'https://pinterest.com'
331 ITEM_SELECTOR = '.pinImageDim' 333 ITEM_SELECTOR = '.pinImageDim'
332 IS_SINGLE_PAGE_APP = True 334 IS_SINGLE_PAGE_APP = True
333 ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented. 335 ITEMS_TO_VISIT = 8
334 ITEM_VIEW_TIME_IN_SECONDS = 5 336 ITEM_VIEW_TIME_IN_SECONDS = 5
335 INCREMENT_INDEX_AFTER_EACH_ITEM = True 337 INCREMENT_INDEX_AFTER_EACH_ITEM = True
336 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 338 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
337 339
338 def _Login(self, action_runner): 340 def _Login(self, action_runner):
339 pinterest_login.LoginDesktopAccount(action_runner, 'googletest', 341 pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
340 self.credentials_path) 342 self.credentials_path)
341 343
342 def _ViewMediaItem(self, action_runner, index): 344 def _ViewMediaItem(self, action_runner, index):
343 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index) 345 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index)
(...skipping 11 matching lines...) Expand all
355 inner_save_function = 'document.querySelector(".nameAndIcons")' 357 inner_save_function = 'document.querySelector(".nameAndIcons")'
356 action_runner.WaitForElement(element_function=inner_save_function) 358 action_runner.WaitForElement(element_function=inner_save_function)
357 action_runner.ClickElement(element_function=inner_save_function) 359 action_runner.ClickElement(element_function=inner_save_function)
358 action_runner.Wait(1) # Wait to make navigation realistic. 360 action_runner.Wait(1) # Wait to make navigation realistic.
359 361
360 # Close selection. 362 # Close selection.
361 x_element_function = ('document.querySelector(' 363 x_element_function = ('document.querySelector('
362 '".Button.borderless.close.visible")') 364 '".Button.borderless.close.visible")')
363 action_runner.ClickElement(element_function=x_element_function) 365 action_runner.ClickElement(element_function=x_element_function)
364 action_runner.Wait(1) # Wait to make navigation realistic. 366 action_runner.Wait(1) # Wait to make navigation realistic.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698