Chromium Code Reviews| Index: tools/perf/page_sets/system_health/browsing_stories.py |
| diff --git a/tools/perf/page_sets/system_health/browsing_stories.py b/tools/perf/page_sets/system_health/browsing_stories.py |
| index 8d5ac935d8503c05d11bece299827635e1659110..e78331677a57fde2f2f6ea6be4897f562b79a5f8 100644 |
| --- a/tools/perf/page_sets/system_health/browsing_stories.py |
| +++ b/tools/perf/page_sets/system_health/browsing_stories.py |
| @@ -51,19 +51,14 @@ class _BrowsingStory(system_health_story.SystemHealthStory): |
| self._WaitForNavigation(action_runner) |
| -############################################################################## |
| -# News browsing stories. |
| -############################################################################## |
| - |
| - |
| -class _NewsBrowsingStory(_BrowsingStory): |
| - """Abstract base class for news user stories. |
| +class _ArticleBrowsingStory(_BrowsingStory): |
| + """Abstract base class for user stories browsing news / shopping articles. |
| - A news story imitates browsing a news website: |
| + An article browsing story imitates browsing a articles: |
| 1. Load the main page. |
| - 2. Open and scroll the first news item. |
| + 2. Open and scroll the first article. |
| 3. Go back to the main page and scroll it. |
| - 4. Open and scroll the second news item. |
| + 4. Open and scroll the second article. |
| 5. Go back to the main page and scroll it. |
| 6. etc. |
| """ |
| @@ -77,11 +72,11 @@ class _NewsBrowsingStory(_BrowsingStory): |
| def _DidLoadDocument(self, action_runner): |
| for i in xrange(self.ITEMS_TO_VISIT): |
| self._NavigateToItem(action_runner, i) |
| - self._ReadNewsItem(action_runner) |
| + self._ReadNextArticle(action_runner) |
| self._NavigateBack(action_runner) |
| self._ScrollMainPage(action_runner) |
| - def _ReadNewsItem(self, action_runner): |
| + def _ReadNextArticle(self, action_runner): |
| action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS/2.0) |
| action_runner.RepeatableBrowserDrivenScroll( |
| @@ -94,7 +89,12 @@ class _NewsBrowsingStory(_BrowsingStory): |
| repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) |
| -class CnnStory(_NewsBrowsingStory): |
| +############################################################################## |
| +# News browsing stories. |
| +############################################################################## |
| + |
| + |
| +class CnnStory(_ArticleBrowsingStory): |
| """The second top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:cnn' |
| URL = 'http://edition.cnn.com/' |
| @@ -103,7 +103,7 @@ class CnnStory(_NewsBrowsingStory): |
| TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| -class FacebookMobileStory(_NewsBrowsingStory): |
| +class FacebookMobileStory(_ArticleBrowsingStory): |
| NAME = 'browse:social:facebook' |
| URL = 'https://www.facebook.com/rihanna' |
| ITEM_SELECTOR = 'article ._5msj' |
| @@ -111,9 +111,10 @@ class FacebookMobileStory(_NewsBrowsingStory): |
| # (crbug.com/631022) |
| MAIN_PAGE_SCROLL_REPEAT = 1 |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| -class FacebookDesktopStory(_NewsBrowsingStory): |
| +class FacebookDesktopStory(_ArticleBrowsingStory): |
| NAME = 'browse:social:facebook' |
| URL = 'https://www.facebook.com/rihanna' |
| ITEM_SELECTOR = '._4-eo' |
| @@ -123,7 +124,7 @@ class FacebookDesktopStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| -class FlipboardMobileStory(_NewsBrowsingStory): |
| +class FlipboardMobileStory(_ArticleBrowsingStory): |
| NAME = 'browse:news:flipboard' |
| URL = 'https://flipboard.com/explore' |
| IS_SINGLE_PAGE_APP = True |
| @@ -136,7 +137,7 @@ class FlipboardMobileStory(_NewsBrowsingStory): |
| return possible_browser.platform.IsSvelte() # crbug.com/668097 |
| -class FlipboardDesktopStory(_NewsBrowsingStory): |
| +class FlipboardDesktopStory(_ArticleBrowsingStory): |
| NAME = 'browse:news:flipboard' |
| URL = 'https://flipboard.com/explore' |
| IS_SINGLE_PAGE_APP = True |
| @@ -146,13 +147,13 @@ class FlipboardDesktopStory(_NewsBrowsingStory): |
| # crbug.com/657665 for win and mac |
| @decorators.Disabled('win', 'mac') |
| -class HackerNewsStory(_NewsBrowsingStory): |
| +class HackerNewsStory(_ArticleBrowsingStory): |
| NAME = 'browse:news:hackernews' |
| URL = 'https://news.ycombinator.com' |
| ITEM_SELECTOR = '.athing .title > a' |
| -class NytimesMobileStory(_NewsBrowsingStory): |
| +class NytimesMobileStory(_ArticleBrowsingStory): |
| """The third top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:nytimes' |
| URL = 'http://mobile.nytimes.com' |
| @@ -162,7 +163,7 @@ class NytimesMobileStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| -class NytimesDesktopStory(_NewsBrowsingStory): |
| +class NytimesDesktopStory(_ArticleBrowsingStory): |
| """The third top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:nytimes' |
| URL = 'http://www.nytimes.com' |
| @@ -172,7 +173,7 @@ class NytimesDesktopStory(_NewsBrowsingStory): |
| # Desktop qq.com opens a news item in a separate tab, for which the back button |
| # does not work. |
| -class QqMobileStory(_NewsBrowsingStory): |
| +class QqMobileStory(_ArticleBrowsingStory): |
| NAME = 'browse:news:qq' |
| URL = 'http://news.qq.com' |
| ITEM_SELECTOR = '.list .full a' |
| @@ -180,7 +181,7 @@ class QqMobileStory(_NewsBrowsingStory): |
| TAGS = [story_tags.INTERNATIONAL] |
| -class RedditDesktopStory(_NewsBrowsingStory): |
| +class RedditDesktopStory(_ArticleBrowsingStory): |
| """The top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:reddit' |
| URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| @@ -188,7 +189,7 @@ class RedditDesktopStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| -class RedditMobileStory(_NewsBrowsingStory): |
| +class RedditMobileStory(_ArticleBrowsingStory): |
| """The top website in http://www.alexa.com/topsites/category/News""" |
| NAME = 'browse:news:reddit' |
| URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| @@ -197,7 +198,7 @@ class RedditMobileStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| -class TwitterMobileStory(_NewsBrowsingStory): |
| +class TwitterMobileStory(_ArticleBrowsingStory): |
| NAME = 'browse:social:twitter' |
| URL = 'https://www.twitter.com/nasa' |
| ITEM_SELECTOR = '.Tweet-text' |
| @@ -206,7 +207,7 @@ class TwitterMobileStory(_NewsBrowsingStory): |
| @decorators.Disabled('win') # crbug.com/662971 |
| -class TwitterDesktopStory(_NewsBrowsingStory): |
| +class TwitterDesktopStory(_ArticleBrowsingStory): |
| NAME = 'browse:social:twitter' |
| URL = 'https://www.twitter.com/nasa' |
| IS_SINGLE_PAGE_APP = True |
| @@ -214,7 +215,7 @@ class TwitterDesktopStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| -class WashingtonPostMobileStory(_NewsBrowsingStory): |
| +class WashingtonPostMobileStory(_ArticleBrowsingStory): |
| """Progressive website""" |
| NAME = 'browse:news:washingtonpost' |
| URL = 'https://www.washingtonpost.com/pwa' |
| @@ -242,7 +243,7 @@ class WashingtonPostMobileStory(_NewsBrowsingStory): |
| @decorators.Disabled('win') # crbug.com/673775 |
| -class GoogleDesktopStory(_NewsBrowsingStory): |
| +class GoogleDesktopStory(_ArticleBrowsingStory): |
| """ |
| A typical google search story: |
| _ Start at https://www.google.com/search?q=flower |
| @@ -293,7 +294,7 @@ class GoogleDesktopStory(_NewsBrowsingStory): |
| action_runner.ScrollPage() |
| -class GoogleIndiaDesktopStory(_NewsBrowsingStory): |
| +class GoogleIndiaDesktopStory(_ArticleBrowsingStory): |
| """ |
| A typical google search story in India: |
| 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` |
| @@ -487,3 +488,137 @@ class PinterestDesktopStory(_MediaBrowsingStory): |
| '".Button.borderless.close.visible")') |
| action_runner.ClickElement(element_function=x_element_function) |
| action_runner.Wait(1) # Wait to make navigation realistic. |
| + |
| + |
| +# Instagram requires navigate back to view next photo So, use |
| +# ArticleBrowsingStory. |
| +class InstagramMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:media:instagram' |
|
perezju
2017/04/11 09:43:35
nit: let's call this browse:social:instagram.
ssid
2017/04/11 21:52:55
Done.
|
| + URL = 'https://www.instagram.com/badgalriri/' |
| + ITEM_SELECTOR = '[class=\\"_8mlbc _vbtk2 _t5r8b\\"]' |
| + ITEMS_TO_VISIT = 8 |
| + IS_SINGLE_PAGE_APP = True |
| + |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + |
| +############################################################################## |
| +# Emerging market browsing stories. |
| +############################################################################## |
| + |
| + |
| +class BrowseFlipKartMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:shopping:flipkart' |
| + URL = 'https://flipkart.com/search?q=Mobile%20phone' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEM_SELECTOR = '.mEOukM' |
| + BACK_SELECTOR = '._3NH1qf' |
| + ITEMS_TO_VISIT = 4 |
| + IS_SINGLE_PAGE_APP = True |
| + |
| + def _NavigateBack(self, action_runner): |
| + action_runner.ClickElement(selector=self.BACK_SELECTOR) |
| + |
| + |
| +class BrowseAmazonMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:shopping:amazon' |
| + URL = 'https://www.amazon.co.in/s/?field-keywords=Mobile' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEM_SELECTOR = '.aw-search-results' |
| + ITEMS_TO_VISIT = 4 |
| + |
| + |
| +class BrowseLazadaMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:shopping:lazada' |
| + URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEM_SELECTOR = '.merchandise__link' |
| + ITEMS_TO_VISIT = 1 |
| + |
| + |
| +class BrowseAvitoMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:shopping:avito' |
| + URL = 'https://www.avito.ru/rossiya' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEM_SELECTOR = '.item-link' |
| + ITEMS_TO_VISIT = 4 |
| + |
| + |
| +class BrowseTOIMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:news:toi' |
| + URL = 'http://m.timesofindia.com' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEMS_TO_VISIT = 4 |
| + ITEM_SELECTOR = '.dummy-img' |
| + |
| + |
| +class BrowseGloboMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:news:globo' |
| + URL = 'http://www.globo.com' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + ITEMS_TO_VISIT = 4 |
| + ITEM_SELECTOR = '.hui-premium__title' |
| + |
| + |
| +############################################################################## |
| +# Maps browsing stories. |
| +############################################################################## |
| + |
| + |
| +class GoogleMapsMobileStory(system_health_story.SystemHealthStory): |
| + NAME = 'browse:tools:maps' |
| + URL = 'https://maps.google.com/' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + _MAPS_SEARCH_BOX_SELECTOR = '.ml-searchbox-placeholder' |
| + _RESTAURANTS_LOADED = '.ml-panes-categorical-list-results' |
| + _SEARCH_NEW_AREA_SELECTOR = '.ml-reissue-search-button-inner' |
| + _RESTAURANTS_LINK = '.ml-entity-list-item-info' |
| + _DIRECTIONS_LINK = '[class="ml-button ml-inner-button-directions-fab"]' |
| + _DIRECTIONS_LOADED = ('[class="ml-fab-inner ' |
| + 'ml-button ml-button-navigation-fab"]') |
| + _MAP_LAYER = '.ml-map' |
| + |
| + def _DidLoadDocument(self, action_runner): |
| + # Submit search query. |
| + self._ClickLink(self._MAPS_SEARCH_BOX_SELECTOR, action_runner) |
| + action_runner.EnterText('restaurants near me') |
| + action_runner.PressKey('Return') |
| + action_runner.WaitForElement(selector=self._RESTAURANTS_LOADED) |
| + action_runner.WaitForNetworkQuiescence() |
| + action_runner.Wait(4) # User looking at restaurants |
| + |
| + # Open the restaurant list and select the first. |
| + self._ClickLink(self._RESTAURANTS_LOADED, action_runner) |
| + action_runner.WaitForElement(selector=self._RESTAURANTS_LINK) |
| + action_runner.Wait(3) # User reads about restaurant |
| + self._ClickLink(self._RESTAURANTS_LINK, action_runner) |
| + action_runner.Wait(1) # Reading description |
| + |
| + # Open directions to the restaurant from Google. |
| + self._ClickLink(self._DIRECTIONS_LINK, action_runner) |
| + action_runner.Wait(0.5) |
| + action_runner.EnterText('Google Mountain View') |
| + action_runner.PressKey('Return') |
| + action_runner.WaitForElement(selector=self._DIRECTIONS_LOADED) |
| + action_runner.PinchElement(selector=self._MAP_LAYER) |
| + action_runner.WaitForNetworkQuiescence() |
| + action_runner.Wait(2) # Seeing direction |
| + |
| + def _ClickLink(self, selector, action_runner): |
| + action_runner.WaitForElement(selector=selector) |
| + action_runner.ClickElement(selector=selector) |