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

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

Issue 2383883002: [System Health] Add browsing user stories for pinterest and tumblr. (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
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
9
8 from telemetry import decorators 10 from telemetry import decorators
9 11
10 12
11 class _BrowsingStory(system_health_story.SystemHealthStory): 13 class _BrowsingStory(system_health_story.SystemHealthStory):
12 """Abstract base class for browsing stories. 14 """Abstract base class for browsing stories.
13 15
14 A browsing story visits items on the main page. Subclasses provide 16 A browsing story visits items on the main page. Subclasses provide
15 CSS selector to identify the items and implement interaction using 17 CSS selector to identify the items and implement interaction using
16 the helper methods of this class. 18 the helper methods of this class.
17 """ 19 """
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 296
295 class FacebookPhotosDesktopStory(_MediaBrowsingStory): 297 class FacebookPhotosDesktopStory(_MediaBrowsingStory):
296 NAME = 'browse:media:facebook_photos' 298 NAME = 'browse:media:facebook_photos'
297 URL = ( 299 URL = (
298 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater') 300 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater')
299 ITEM_SELECTOR = '.snowliftPager.next' 301 ITEM_SELECTOR = '.snowliftPager.next'
300 # Recording currently does not work. The page gets stuck in the 302 # Recording currently does not work. The page gets stuck in the
301 # theater viewer. 303 # theater viewer.
302 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS 304 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS
303 IS_SINGLE_PAGE_APP = True 305 IS_SINGLE_PAGE_APP = True
306
307
308 class TumblrDesktopStory(_MediaBrowsingStory):
309 NAME = 'browse:media:tumblr'
310 URL = 'https://tumblr.com/search/gifs'
311 ITEM_SELECTOR = '.photo'
312 IS_SINGLE_PAGE_APP = True
313 ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented.
314 ITEM_VIEW_TIME_IN_SECONDS = 5
315
316 def _ViewMediaItem(self, action_runner):
317 super(TumblrDesktopStory, self)._ViewMediaItem(action_runner)
318 action_runner.MouseClick(selector='#tumblr_lightbox_center_image')
319 self.ITEM_SELECTOR_INDEX += 1
petrcermak 2016/10/03 09:01:23 This works, but it's very hacky. Please don't shad
rnephew (Reviews Here) 2016/10/03 16:57:13 Done.
320
321
322 class PinterestDesktopStory(_MediaBrowsingStory):
323 NAME = 'browse:media:pinterest'
324 URL = 'https://pinterest.com'
325 ITEM_SELECTOR = '.pinImageDim'
326 IS_SINGLE_PAGE_APP = True
327 ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented.
328 ITEM_VIEW_TIME_IN_SECONDS = 5
329
330 def _Login(self, action_runner):
331 pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
332 self.credentials_path)
333
334 def _ViewMediaItem(self, action_runner):
335 super(PinterestDesktopStory, self)._ViewMediaItem(action_runner)
336 # To imitate real user interaction, we do not want to pin every post.
337 # We will only pin every other post.
338 if self.ITEM_SELECTOR_INDEX % 2 == 0:
339 # Pin the selection.
340 save_function = ('document.querySelector('
341 '".Button.Module.ShowModalButton.btn.hasIcon.hasText.'
342 'isBrioFlat.medium.primary.primaryOnHover.repin.'
343 'pinActionBarButton.isBrioFlat.rounded")')
344 action_runner.ClickElement(element_function=save_function)
345 action_runner.Wait(1) # Wait to make navigation realistic.
346 # Select which board to pin to.
347 inner_save_function = 'document.querySelector(".nameAndIcons")'
348 action_runner.WaitForElement(element_function=inner_save_function)
349 action_runner.ClickElement(element_function=inner_save_function)
350 action_runner.Wait(1) # Wait to make navigation realistic.
351
352 # Close selection.
353 x_element_function = ('document.querySelector('
354 '".Button.borderless.close.visible")')
355 action_runner.ClickElement(element_function=x_element_function)
356 action_runner.Wait(1) # Wait to make navigation realistic.
357 self.ITEM_SELECTOR_INDEX += 1
petrcermak 2016/10/03 09:01:23 ditto: don't shadow a constant
rnephew (Reviews Here) 2016/10/03 16:57:13 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698