Commit 022a7317 authored by rnephew's avatar rnephew Committed by Commit bot

[System Health] Add browsing user stories for pinterest and tumblr.

The stories go to their respective sites and open a series of images
and close them. Pinterest will also 'pin' every other image it clicks
on.

BUG=646392

Review-Url: https://codereview.chromium.org/2383883002
Cr-Commit-Position: refs/heads/master@{#422886}
parent 9a7916b5
......@@ -106,7 +106,11 @@
],
"system_health_desktop_032.wpr": [
"play:media:pandora"
],
"system_health_desktop_033.wpr": [
"browse:media:pinterest",
"browse:media:tumblr"
]
},
"description": "Describes the Web Page Replay archives for a story set. Don't edit by hand! Use record_wpr for updating."
}
\ No newline at end of file
}
033943a78acc34d60a6d3342922f3ec5976b8391
\ No newline at end of file
# Copyright 2016 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 page_sets.login_helpers import login_utils
def LoginDesktopAccount(action_runner, credential,
credentials_path=login_utils.DEFAULT_CREDENTIAL_PATH):
"""Logs in into a Dropbox account.
This function navigates the tab into Dropbox's login page and logs in a user
using credentials in |credential| part of the |credentials_path| file.
Args:
action_runner: Action runner responsible for running actions on the page.
credential: The credential to retrieve from the credentials file (string).
credentials_path: The path to credential file (string).
Raises:
exceptions.Error: See ExecuteJavaScript()
for a detailed list of possible exceptions.
"""
account_name, password = login_utils.GetAccountNameAndPassword(
credential, credentials_path=credentials_path)
action_runner.Navigate('https://www.pinterest.com/login/')
action_runner.Wait(1) # Error page happens if this wait is not here.
login_utils.InputWithSelector(
action_runner, '%s@gmail.com' % account_name, 'input[type=email]')
login_utils.InputWithSelector(
action_runner, password, 'input[type=password]')
login_button_function = (
'document.getElementsByClassName("Button Module btn hasText large '
'primary continueButton rounded")[0]')
action_runner.WaitForElement(element_function=login_button_function)
action_runner.ClickElement(element_function=login_button_function)
search_bar_function = (
'document.getElementsByClassName("Input Module field")[0]')
action_runner.WaitForElement(element_function=search_bar_function)
......@@ -5,6 +5,8 @@
from page_sets.system_health import platforms
from page_sets.system_health import system_health_story
from page_sets.login_helpers import pinterest_login
from telemetry import decorators
......@@ -233,13 +235,19 @@ class _MediaBrowsingStory(_BrowsingStory):
ITEM_VIEW_TIME_IN_SECONDS = 3
ITEMS_TO_VISIT = 15
ITEM_SELECTOR_INDEX = 0
INCREMENT_INDEX_AFTER_EACH_ITEM = False
def _DidLoadDocument(self, action_runner):
index = self.ITEM_SELECTOR_INDEX
for _ in xrange(self.ITEMS_TO_VISIT):
self._NavigateToItem(action_runner, self.ITEM_SELECTOR_INDEX)
self._ViewMediaItem(action_runner)
self._NavigateToItem(action_runner, index)
self._ViewMediaItem(action_runner, index)
if self.INCREMENT_INDEX_AFTER_EACH_ITEM:
index += 1
def _ViewMediaItem(self, action_runner):
def _ViewMediaItem(self, action_runner, index):
del index # Unused.
action_runner.tab.WaitForDocumentReadyStateToBeComplete()
action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS)
......@@ -300,3 +308,57 @@ class FacebookPhotosDesktopStory(_MediaBrowsingStory):
# theater viewer.
SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS
IS_SINGLE_PAGE_APP = True
class TumblrDesktopStory(_MediaBrowsingStory):
NAME = 'browse:media:tumblr'
URL = 'https://tumblr.com/search/gifs'
ITEM_SELECTOR = '.photo'
IS_SINGLE_PAGE_APP = True
ITEMS_TO_VISIT = 2 # Increase when crbug.com/651909 is implemented.
ITEM_VIEW_TIME_IN_SECONDS = 5
INCREMENT_INDEX_AFTER_EACH_ITEM = True
SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS # crbug.com/651909.
def _ViewMediaItem(self, action_runner, index):
super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index)
action_runner.MouseClick(selector='#tumblr_lightbox_center_image')
class PinterestDesktopStory(_MediaBrowsingStory):
NAME = 'browse:media:pinterest'
URL = 'https://pinterest.com'
ITEM_SELECTOR = '.pinImageDim'
IS_SINGLE_PAGE_APP = True
ITEMS_TO_VISIT = 5 # Increase when crbug.com/651909 is implemented.
ITEM_VIEW_TIME_IN_SECONDS = 5
INCREMENT_INDEX_AFTER_EACH_ITEM = True
SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
def _Login(self, action_runner):
pinterest_login.LoginDesktopAccount(action_runner, 'googletest',
self.credentials_path)
def _ViewMediaItem(self, action_runner, index):
super(PinterestDesktopStory, self)._ViewMediaItem(action_runner, index)
# To imitate real user interaction, we do not want to pin every post.
# We will only pin every other post.
if index % 2 == 0:
# Pin the selection.
save_function = ('document.querySelector('
'".Button.Module.ShowModalButton.btn.hasIcon.hasText.'
'isBrioFlat.medium.primary.primaryOnHover.repin.'
'pinActionBarButton.isBrioFlat.rounded")')
action_runner.ClickElement(element_function=save_function)
action_runner.Wait(1) # Wait to make navigation realistic.
# Select which board to pin to.
inner_save_function = 'document.querySelector(".nameAndIcons")'
action_runner.WaitForElement(element_function=inner_save_function)
action_runner.ClickElement(element_function=inner_save_function)
action_runner.Wait(1) # Wait to make navigation realistic.
# Close selection.
x_element_function = ('document.querySelector('
'".Button.borderless.close.visible")')
action_runner.ClickElement(element_function=x_element_function)
action_runner.Wait(1) # Wait to make navigation realistic.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment