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..6cabc99f00d03685f9dbe6e422720295cf2b9395 100644 |
| --- a/tools/perf/page_sets/system_health/browsing_stories.py |
| +++ b/tools/perf/page_sets/system_health/browsing_stories.py |
| @@ -1,4 +1,3 @@ |
| -# encoding: utf-8 |
| # 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. |
| @@ -7,13 +6,10 @@ from page_sets.system_health import platforms |
| from page_sets.system_health import story_tags |
| from page_sets.system_health import system_health_story |
| -from page_sets.login_helpers import pinterest_login |
| - |
| from telemetry import decorators |
| -from telemetry.util import js_template |
| -class _BrowsingStory(system_health_story.SystemHealthStory): |
| +class BrowsingStory(system_health_story.SystemHealthStory): |
| """Abstract base class for browsing stories. |
| A browsing story visits items on the main page. Subclasses provide |
| @@ -51,19 +47,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 +68,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 +85,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 +99,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 +109,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 +119,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 +132,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 +142,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 +158,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 +168,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 +176,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 +184,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 +193,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 +202,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 +210,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' |
| @@ -237,253 +233,102 @@ class WashingtonPostMobileStory(_NewsBrowsingStory): |
| ############################################################################## |
| -# Search browsing stories. |
| -############################################################################## |
| - |
| - |
| -@decorators.Disabled('win') # crbug.com/673775 |
| -class GoogleDesktopStory(_NewsBrowsingStory): |
| - """ |
| - A typical google search story: |
| - _ Start at https://www.google.com/search?q=flower |
| - _ Click on the wikipedia link & navigate to |
| - https://en.wikipedia.org/wiki/Flower |
| - _ Scroll down the wikipedia page about flower. |
| - _ Back to the search main page. |
| - _ Refine the search query to 'flower delivery'. |
| - _ Scroll down the page. |
| - _ Click the next page result of 'flower delivery'. |
| - _ Scroll the search page. |
| - |
| - """ |
| - NAME = 'browse:search:google' |
| - URL = 'https://www.google.com/search?q=flower' |
| - _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| - _SEARCH_PAGE_2_SELECTOR = 'a[aria-label=\'Page 2\']' |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| - |
| - def _DidLoadDocument(self, action_runner): |
| - # Click on flower Wikipedia link. |
| - action_runner.Wait(2) |
| - action_runner.ClickElement(text='Flower - Wikipedia') |
| - action_runner.WaitForNavigate() |
| - |
| - # Scroll the flower Wikipedia page, then navigate back. |
| - action_runner.Wait(2) |
| - action_runner.ScrollPage() |
| - action_runner.Wait(2) |
| - action_runner.NavigateBack() |
| - |
| - # Click on the search box. |
| - action_runner.WaitForElement(selector=self._SEARCH_BOX_SELECTOR) |
| - action_runner.ClickElement(selector=self._SEARCH_BOX_SELECTOR) |
| - action_runner.Wait(2) |
| - |
| - # Submit search query. |
| - action_runner.EnterText(' delivery') |
| - action_runner.Wait(0.5) |
| - action_runner.PressKey('Return') |
| - |
| - # Scroll down & click next search result page. |
| - action_runner.Wait(2) |
| - action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| - action_runner.Wait(2) |
| - action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| - action_runner.Wait(2) |
| - action_runner.ScrollPage() |
| - |
| - |
| -class GoogleIndiaDesktopStory(_NewsBrowsingStory): |
| - """ |
| - 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` |
| - 2. Scroll down the page. |
| - 3. Refine the query & click search box, which navigates to |
| - https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2&rct=j#q=%E0%A4%AB%E0%A5%82%E0%A4%B2+%E0%A4%B5%E0%A4%BF%E0%A4%A4%E0%A4%B0%E0%A4%A3 |
| - 4. Scroll down the page. |
| - 5. Click the next page result |
| - 6. Scroll the search result page. |
| - |
| - """ |
| - NAME = 'browse:search:google_india' |
| - URL = 'https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2' |
| - _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| - _SEARCH_BUTTON_SELECTOR = 'button[aria-label="Google Search"]' |
| - _SEARCH_PAGE_2_SELECTOR = 'a[aria-label=\'Page 2\']' |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| - TAGS = [story_tags.INTERNATIONAL] |
| - |
| - def _DidLoadDocument(self, action_runner): |
| - action_runner.Wait(2) |
| - action_runner.ScrollPage() |
| - action_runner.Wait(2) |
| - |
| - action_runner.ScrollPage(direction='up') |
| - |
| - # Refine search query in the search box. |
| - # TODO(nednguyen): replace this with input text gesture to make it more |
| - # realistic. |
| - action_runner.ExecuteJavaScript( |
| - js_template.Render( |
| - 'document.querySelector({{ selector }}).value += "वितरण";', |
| - selector=self._SEARCH_BOX_SELECTOR)) |
| - action_runner.Wait(2) |
| - action_runner.ClickElement(selector=self._SEARCH_BUTTON_SELECTOR) |
| - |
| - # Scroll down & click next search result page. |
| - action_runner.Wait(2) |
| - action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| - action_runner.Wait(2) |
| - action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| - action_runner.Wait(2) |
| - action_runner.ScrollPage() |
| - |
| - |
| -############################################################################## |
| -# Media browsing stories. |
| +# Emerging market browsing stories. |
| ############################################################################## |
| -class _MediaBrowsingStory(_BrowsingStory): |
| - """Abstract base class for media user stories |
| - |
| - A media story imitates browsing a website with photo or video content: |
| - 1. Load a page showing a media item |
| - 2. Click on the next link to go to the next media item |
| - 3. etc. |
| - """ |
| - |
| - ABSTRACT_STORY = True |
| - 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, index) |
| - self._ViewMediaItem(action_runner, index) |
| - if self.INCREMENT_INDEX_AFTER_EACH_ITEM: |
| - index += 1 |
| +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 _ViewMediaItem(self, action_runner, index): |
| - del index # Unused. |
| - action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| - action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) |
| + def _NavigateBack(self, action_runner): |
| + action_runner.ClickElement(selector=self.BACK_SELECTOR) |
| -class ImgurMobileStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:imgur' |
| - URL = 'http://imgur.com/gallery/5UlBN' |
| - ITEM_SELECTOR = '.Navbar-customAction' |
| +class BrowseAmazonMobileStory(ArticleBrowsingStory): |
| + NAME = 'browse:shopping:amazon' |
| + URL = 'https://www.amazon.co.in/s/?field-keywords=Mobile' |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| - IS_SINGLE_PAGE_APP = True |
| - |
| + TAGS = [story_tags.EMERGING_MARKET] |
| -# crbug.com/704197 for win and mac |
| -@decorators.Disabled('win', 'mac') |
| -class ImgurDesktopStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:imgur' |
| - URL = 'http://imgur.com/gallery/5UlBN' |
| - ITEM_SELECTOR = '.navNext' |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| - IS_SINGLE_PAGE_APP = True |
| + ITEM_SELECTOR = ('[class=\\"a-spacing-none a-link-normal sx-table-product ' |
| + 'aw-search-results\\"]') |
|
perezju
2017/04/10 10:13:56
I'm not expert on CSS selectors, but is there a wa
ssid
2017/04/11 03:55:57
Cool. Didn't know this was possible.
|
| + ITEMS_TO_VISIT = 4 |
| -class YouTubeMobileStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:youtube' |
| - URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| - ITEM_SELECTOR = '._mhgb > a' |
| +class BrowseLazadaMobileStory(ArticleBrowsingStory): |
| + NAME = 'browse:shopping:lazada' |
| + URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch' |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| - IS_SINGLE_PAGE_APP = True |
| - ITEM_SELECTOR_INDEX = 3 |
| - TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| + TAGS = [story_tags.EMERGING_MARKET] |
| - |
| -class YouTubeDesktopStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:youtube' |
| - URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| - ITEM_SELECTOR = '.yt-uix-simple-thumb-related' |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| - IS_SINGLE_PAGE_APP = True |
| - # A longer view time allows videos to load and play. |
| - ITEM_VIEW_TIME_IN_SECONDS = 5 |
| - ITEMS_TO_VISIT = 8 |
| - ITEM_SELECTOR_INDEX = 3 |
| - PLATFORM_SPECIFIC = True |
| - TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| + ITEM_SELECTOR = '.merchandise__link' |
| + ITEMS_TO_VISIT = 1 |
| -class FacebookPhotosMobileStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:facebook_photos' |
| - URL = ( |
| - 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&source=54&ref=page_internal') |
| - ITEM_SELECTOR = '._57-r.touchable' |
| +class BrowseTOIMobileStory(ArticleBrowsingStory): |
| + NAME = 'browse:news:toi' |
| + URL = 'http://m.timesofindia.com' |
| SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| - IS_SINGLE_PAGE_APP = True |
| - ITEM_SELECTOR_INDEX = 0 |
| + TAGS = [story_tags.EMERGING_MARKET] |
| + ITEMS_TO_VISIT = 4 |
| + ITEM_SELECTOR = '[onerror=\\"this.style.display=\'none\'\\"]' |
|
perezju
2017/04/10 10:13:56
:( I guess there is no better way to match these i
ssid
2017/04/11 03:55:57
There is this other way. But i thought dummy_img l
|
| -class FacebookPhotosDesktopStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:facebook_photos' |
| - URL = ( |
| - 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/10153911739606676/?type=3&theater') |
| - ITEM_SELECTOR = '.snowliftPager.next' |
| - # Recording currently does not work. The page gets stuck in the |
| - # theater viewer. |
| - SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| - IS_SINGLE_PAGE_APP = True |
| +############################################################################## |
| +# Maps browsing stories. |
| +############################################################################## |
| -class TumblrDesktopStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:tumblr' |
| - URL = 'https://tumblr.com/search/gifs' |
| - ITEM_SELECTOR = '.photo' |
| - IS_SINGLE_PAGE_APP = True |
| - ITEMS_TO_VISIT = 8 |
| - INCREMENT_INDEX_AFTER_EACH_ITEM = True |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| - def _ViewMediaItem(self, action_runner, index): |
| - super(TumblrDesktopStory, self)._ViewMediaItem(action_runner, index) |
| - action_runner.MouseClick(selector='#tumblr_lightbox_center_image') |
| - action_runner.Wait(1) # To make browsing more realistic. |
| +class GoogleMapsMobileStory(ArticleBrowsingStory): |
|
perezju
2017/04/10 10:13:56
does this really need to subclass ArticleBrowsingS
ssid
2017/04/11 03:55:57
Sorry fixed.
|
| + NAME = 'browse:tools:maps' |
| + URL = 'https://maps.google.com/' |
| + SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| + TAGS = [story_tags.EMERGING_MARKET] |
| -class PinterestDesktopStory(_MediaBrowsingStory): |
| - NAME = 'browse:media:pinterest' |
| - URL = 'https://pinterest.com' |
| - ITEM_SELECTOR = '.pinImageDim' |
| - IS_SINGLE_PAGE_APP = True |
| - ITEMS_TO_VISIT = 8 |
| - INCREMENT_INDEX_AFTER_EACH_ITEM = True |
| - SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| + _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 _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. |
| + 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) |