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

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

Issue 2612053002: Stop browse:social:twitter scrolling wrong element (Closed)
Patch Set: Remove random other commit. Created 3 years, 11 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
11 11
12 12
13 class _BrowsingStory(system_health_story.SystemHealthStory): 13 class _BrowsingStory(system_health_story.SystemHealthStory):
14 """Abstract base class for browsing stories. 14 """Abstract base class for browsing stories.
15 15
16 A browsing story visits items on the main page. Subclasses provide 16 A browsing story visits items on the main page. Subclasses provide
17 CSS selector to identify the items and implement interaction using 17 CSS selector to identify the items and implement interaction using
18 the helper methods of this class. 18 the helper methods of this class.
19 """ 19 """
20 20
21 IS_SINGLE_PAGE_APP = False 21 IS_SINGLE_PAGE_APP = False
22 ITEM_SELECTOR = NotImplemented 22 ITEM_SELECTOR = NotImplemented
23 # Defaults to using the body element if not set.
24 CONTAINER_SELECTOR = None
23 ABSTRACT_STORY = True 25 ABSTRACT_STORY = True
24 26
25 def _WaitForNavigation(self, action_runner): 27 def _WaitForNavigation(self, action_runner):
26 if not self.IS_SINGLE_PAGE_APP: 28 if not self.IS_SINGLE_PAGE_APP:
27 action_runner.WaitForNavigate() 29 action_runner.WaitForNavigate()
28 30
29 def _NavigateToItem(self, action_runner, index): 31 def _NavigateToItem(self, action_runner, index):
30 item_selector = 'document.querySelectorAll("%s")[%d]' % ( 32 item_selector = 'document.querySelectorAll("%s")[%d]' % (
31 self.ITEM_SELECTOR, index) 33 self.ITEM_SELECTOR, index)
32 # Only scrolls if element is not currently in viewport. 34 # Only scrolls if element is not currently in viewport.
33 action_runner.WaitForElement(element_function=item_selector) 35 action_runner.WaitForElement(element_function=item_selector)
34 action_runner.ScrollPageToElement(element_function=item_selector) 36 action_runner.ScrollPageToElement(
37 element_function=item_selector,
38 container_selector=self.CONTAINER_SELECTOR)
35 self._ClickLink(action_runner, item_selector) 39 self._ClickLink(action_runner, item_selector)
36 40
37 def _ClickLink(self, action_runner, element_function): 41 def _ClickLink(self, action_runner, element_function):
38 action_runner.WaitForElement(element_function=element_function) 42 action_runner.WaitForElement(element_function=element_function)
39 action_runner.ClickElement(element_function=element_function) 43 action_runner.ClickElement(element_function=element_function)
40 self._WaitForNavigation(action_runner) 44 self._WaitForNavigation(action_runner)
41 45
42 def _NavigateBack(self, action_runner): 46 def _NavigateBack(self, action_runner):
43 action_runner.NavigateBack() 47 action_runner.NavigateBack()
44 self._WaitForNavigation(action_runner) 48 self._WaitForNavigation(action_runner)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' 191 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week'
188 IS_SINGLE_PAGE_APP = True 192 IS_SINGLE_PAGE_APP = True
189 ITEM_SELECTOR = '.PostHeader__post-title-line' 193 ITEM_SELECTOR = '.PostHeader__post-title-line'
190 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 194 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
191 195
192 196
193 class TwitterMobileStory(_NewsBrowsingStory): 197 class TwitterMobileStory(_NewsBrowsingStory):
194 NAME = 'browse:social:twitter' 198 NAME = 'browse:social:twitter'
195 URL = 'https://www.twitter.com/nasa' 199 URL = 'https://www.twitter.com/nasa'
196 ITEM_SELECTOR = '.Tweet-text' 200 ITEM_SELECTOR = '.Tweet-text'
201 CONTAINER_SELECTOR = '.NavigationSheet'
197 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 202 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
198 203
199 204
200 @decorators.Disabled('win', # crbug.com/662971 205 @decorators.Disabled('win', # crbug.com/662971
201 'mac') # crbug.com/663025 206 'mac') # crbug.com/663025
202 class TwitterDesktopStory(_NewsBrowsingStory): 207 class TwitterDesktopStory(_NewsBrowsingStory):
203 NAME = 'browse:social:twitter' 208 NAME = 'browse:social:twitter'
204 URL = 'https://www.twitter.com/nasa' 209 URL = 'https://www.twitter.com/nasa'
205 IS_SINGLE_PAGE_APP = True 210 IS_SINGLE_PAGE_APP = True
206 ITEM_SELECTOR = '.tweet-text' 211 ITEM_SELECTOR = '.tweet-text'
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 inner_save_function = 'document.querySelector(".nameAndIcons")' 429 inner_save_function = 'document.querySelector(".nameAndIcons")'
425 action_runner.WaitForElement(element_function=inner_save_function) 430 action_runner.WaitForElement(element_function=inner_save_function)
426 action_runner.ClickElement(element_function=inner_save_function) 431 action_runner.ClickElement(element_function=inner_save_function)
427 action_runner.Wait(1) # Wait to make navigation realistic. 432 action_runner.Wait(1) # Wait to make navigation realistic.
428 433
429 # Close selection. 434 # Close selection.
430 x_element_function = ('document.querySelector(' 435 x_element_function = ('document.querySelector('
431 '".Button.borderless.close.visible")') 436 '".Button.borderless.close.visible")')
432 action_runner.ClickElement(element_function=x_element_function) 437 action_runner.ClickElement(element_function=x_element_function)
433 action_runner.Wait(1) # Wait to make navigation realistic. 438 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