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..c11a28d91217c578e7ac3ae5fdfa959c37e62f76 100644 |
| --- a/tools/perf/page_sets/system_health/browsing_stories.py |
| +++ b/tools/perf/page_sets/system_health/browsing_stories.py |
| @@ -56,14 +56,14 @@ class _BrowsingStory(system_health_story.SystemHealthStory): |
| ############################################################################## |
| -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 +77,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 +94,7 @@ class _NewsBrowsingStory(_BrowsingStory): |
| repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) |
| -class CnnStory(_NewsBrowsingStory): |
| +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' |
| @@ -113,7 +113,7 @@ class FacebookMobileStory(_NewsBrowsingStory): |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| -class FacebookDesktopStory(_NewsBrowsingStory): |
| +class FacebookDesktopStory(_ArticleBrowsingStory): |
| NAME = 'browse:social:facebook' |
| URL = 'https://www.facebook.com/rihanna' |
| ITEM_SELECTOR = '._4-eo' |
| @@ -123,7 +123,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 +136,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 +146,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 +162,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 +172,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 +180,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 +188,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 +197,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 +206,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 +214,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 +242,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 +293,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 +487,111 @@ class PinterestDesktopStory(_MediaBrowsingStory): |
| '".Button.borderless.close.visible")') |
| action_runner.ClickElement(element_function=x_element_function) |
| action_runner.Wait(1) # Wait to make navigation realistic. |
| + |
| + |
| +############################################################################## |
| +# Emerging market browsing stories. |
| +############################################################################## |
| + |
| + |
| +class MobileNewTabPageStory(system_health_story.SystemHealthStory): |
| + """Story that loads new tab page and opens menu.""" |
| + |
| + NAME = 'browse:chrome:newtab' |
| + URL = 'chrome://newtab' |
| + |
| + def RunPageInteractions(self, action_runner): |
| + package = action_runner.tab.browser.GetBrowserInfo().package_name |
| + platform = action_runner.tab.browser.platform |
| + menu_button = package+':id/menu_button' |
|
perezju
2017/04/04 09:23:38
I think we should add an "app_ui" property to the
ssid
2017/04/04 20:59:49
Done.
|
| + platform.system_ui.WaitForUiNode(resource_id=menu_button) |
| + menu_button = platform.system_ui.GetUiNode(resource_id=menu_button) |
| + menu_button.Tap() |
| + platform.system_ui.WaitForUiNode(resource_id=package+':id/menu_item_text') |
| + |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + |
| +class _ArticleBrowsingStoryEM(_ArticleBrowsingStory): |
|
perezju
2017/04/04 09:23:38
I don't think we need this class. It's better to a
ssid
2017/04/04 20:59:49
Done.
|
| + """Abstract class for browsing stories for emerging markets.""" |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + ABSTRACT_STORY = True |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + |
| +class BrowseFlipKart(_ArticleBrowsingStoryEM): |
| + NAME = 'browse:shopping:flipkart' |
| + URL = 'https://flipkart.com/search?q=Mobile%20phone' |
| + 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 BrowseLazada(_ArticleBrowsingStoryEM): |
| + NAME = 'browse:shopping:lazada' |
| + URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch' |
| + ITEM_SELECTOR = '.merchandise__link' |
| + ITEMS_TO_VISIT = 1 |
| + |
| + |
| +class BrowseTOI(_ArticleBrowsingStoryEM): |
| + NAME='browse:news:toi' |
| + URL='http://m.timesofindia.com' |
| + ITEMS_TO_VISIT = 3 |
| + ITEM_SELECTOR = '[onerror=\\"this.style.display=\'none\'\\"]' |
| + |
| + |
| +class GoogleMapsMobileStory(_ArticleBrowsingStory): |
| + NAME = 'browse:tools:maps' |
| + URL='https://maps.google.co.in/' |
|
mythria
2017/04/05 09:30:15
Is there any reason we start with maps.google.co.i
ssid
2017/04/07 22:18:34
Initially i added .co.in when I didn't have the se
|
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + |
| + _MAPS_SEARCH_BOX_SELECTOR = '.ml-searchbox-placeholder' |
| + _MAPS_ZOOM_IN_SELECTOR = '[aria-label="Zoom in"]' |
|
mythria
2017/04/05 09:30:15
I think this is not required.
ssid
2017/04/07 22:18:34
Done.
|
| + _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"]' |
| + _LOCATION_LINK = '.suggest-query' |
| + _LOCATION_INPUT = 'input[aria-label="Choose starting point"]' |
| + _DIRECTIONS_LOADED = '[class="ml-fab-inner ml-button ml-button-navigation-fab"]' |
|
perezju
2017/04/04 09:23:38
Do sync with Mythri, I think she was also working
ssid
2017/04/04 20:59:49
Yes I had made this similar to the new Maps benchm
mythria
2017/04/05 09:30:15
Thanks for doing this. I was also working on the a
ssid
2017/04/07 22:18:34
Acknowledged.
|
| + |
| + def RunPageInteractions(self, action_runner): |
| + # Click on the search box. |
| + action_runner.WaitForElement(selector=self._MAPS_SEARCH_BOX_SELECTOR) |
| + action_runner.ClickElement(selector=self._MAPS_SEARCH_BOX_SELECTOR) |
| + |
| + # Submit search query. |
| + action_runner.EnterText('restaurants near me') |
| + action_runner.PressKey('Return') |
| + action_runner.WaitForElement(selector=self._RESTAURANTS_LOADED) |
| + action_runner.WaitForNetworkQuiescence() |
| + action_runner.Wait(3) # User looking t restaurants |
|
mythria
2017/04/05 09:30:15
It would be great, if we could add some scrolling
|
| + |
| + # 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.ScrollPage() |
| + action_runner.Wait(1) # Reading review |
| + |
| + # 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.PinchPage(scale_factor=3) |
| + 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) |