| OLD | NEW |
| 1 # encoding: utf-8 | 1 # encoding: utf-8 |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from page_sets.system_health import platforms | 6 from page_sets.system_health import platforms |
| 7 from page_sets.system_health import story_tags | 7 from page_sets.system_health import story_tags |
| 8 from page_sets.system_health import system_health_story | 8 from page_sets.system_health import system_health_story |
| 9 | 9 |
| 10 from page_sets.login_helpers import pinterest_login | 10 from page_sets.login_helpers import pinterest_login |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 def _ClickLink(self, action_runner, element_function): | 44 def _ClickLink(self, action_runner, element_function): |
| 45 action_runner.WaitForElement(element_function=element_function) | 45 action_runner.WaitForElement(element_function=element_function) |
| 46 action_runner.ClickElement(element_function=element_function) | 46 action_runner.ClickElement(element_function=element_function) |
| 47 self._WaitForNavigation(action_runner) | 47 self._WaitForNavigation(action_runner) |
| 48 | 48 |
| 49 def _NavigateBack(self, action_runner): | 49 def _NavigateBack(self, action_runner): |
| 50 action_runner.NavigateBack() | 50 action_runner.NavigateBack() |
| 51 self._WaitForNavigation(action_runner) | 51 self._WaitForNavigation(action_runner) |
| 52 | 52 |
| 53 | 53 |
| 54 ############################################################################## | 54 class _ArticleBrowsingStory(_BrowsingStory): |
| 55 # News browsing stories. | 55 """Abstract base class for user stories browsing news / shopping articles. |
| 56 ############################################################################## | |
| 57 | 56 |
| 58 | 57 An article browsing story imitates browsing a articles: |
| 59 class _NewsBrowsingStory(_BrowsingStory): | |
| 60 """Abstract base class for news user stories. | |
| 61 | |
| 62 A news story imitates browsing a news website: | |
| 63 1. Load the main page. | 58 1. Load the main page. |
| 64 2. Open and scroll the first news item. | 59 2. Open and scroll the first article. |
| 65 3. Go back to the main page and scroll it. | 60 3. Go back to the main page and scroll it. |
| 66 4. Open and scroll the second news item. | 61 4. Open and scroll the second article. |
| 67 5. Go back to the main page and scroll it. | 62 5. Go back to the main page and scroll it. |
| 68 6. etc. | 63 6. etc. |
| 69 """ | 64 """ |
| 70 | 65 |
| 71 ITEM_READ_TIME_IN_SECONDS = 3 | 66 ITEM_READ_TIME_IN_SECONDS = 3 |
| 72 ITEM_SCROLL_REPEAT = 2 | 67 ITEM_SCROLL_REPEAT = 2 |
| 73 ITEMS_TO_VISIT = 4 | 68 ITEMS_TO_VISIT = 4 |
| 74 MAIN_PAGE_SCROLL_REPEAT = 0 | 69 MAIN_PAGE_SCROLL_REPEAT = 0 |
| 75 ABSTRACT_STORY = True | 70 ABSTRACT_STORY = True |
| 76 | 71 |
| 77 def _DidLoadDocument(self, action_runner): | 72 def _DidLoadDocument(self, action_runner): |
| 78 for i in xrange(self.ITEMS_TO_VISIT): | 73 for i in xrange(self.ITEMS_TO_VISIT): |
| 79 self._NavigateToItem(action_runner, i) | 74 self._NavigateToItem(action_runner, i) |
| 80 self._ReadNewsItem(action_runner) | 75 self._ReadNextArticle(action_runner) |
| 81 self._NavigateBack(action_runner) | 76 self._NavigateBack(action_runner) |
| 82 self._ScrollMainPage(action_runner) | 77 self._ScrollMainPage(action_runner) |
| 83 | 78 |
| 84 def _ReadNewsItem(self, action_runner): | 79 def _ReadNextArticle(self, action_runner): |
| 85 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 80 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 86 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS/2.0) | 81 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS/2.0) |
| 87 action_runner.RepeatableBrowserDrivenScroll( | 82 action_runner.RepeatableBrowserDrivenScroll( |
| 88 repeat_count=self.ITEM_SCROLL_REPEAT) | 83 repeat_count=self.ITEM_SCROLL_REPEAT) |
| 89 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS/2.0) | 84 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS/2.0) |
| 90 | 85 |
| 91 def _ScrollMainPage(self, action_runner): | 86 def _ScrollMainPage(self, action_runner): |
| 92 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 87 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 93 action_runner.RepeatableBrowserDrivenScroll( | 88 action_runner.RepeatableBrowserDrivenScroll( |
| 94 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) | 89 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) |
| 95 | 90 |
| 96 | 91 |
| 97 class CnnStory(_NewsBrowsingStory): | 92 ############################################################################## |
| 93 # News browsing stories. |
| 94 ############################################################################## |
| 95 |
| 96 |
| 97 class CnnStory(_ArticleBrowsingStory): |
| 98 """The second top website in http://www.alexa.com/topsites/category/News""" | 98 """The second top website in http://www.alexa.com/topsites/category/News""" |
| 99 NAME = 'browse:news:cnn' | 99 NAME = 'browse:news:cnn' |
| 100 URL = 'http://edition.cnn.com/' | 100 URL = 'http://edition.cnn.com/' |
| 101 ITEM_SELECTOR = '.cd__content > h3 > a' | 101 ITEM_SELECTOR = '.cd__content > h3 > a' |
| 102 ITEMS_TO_VISIT = 2 | 102 ITEMS_TO_VISIT = 2 |
| 103 TAGS = [story_tags.JAVASCRIPT_HEAVY] | 103 TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| 104 | 104 |
| 105 | 105 |
| 106 class FacebookMobileStory(_NewsBrowsingStory): | 106 class FacebookMobileStory(_ArticleBrowsingStory): |
| 107 NAME = 'browse:social:facebook' | 107 NAME = 'browse:social:facebook' |
| 108 URL = 'https://www.facebook.com/rihanna' | 108 URL = 'https://www.facebook.com/rihanna' |
| 109 ITEM_SELECTOR = 'article ._5msj' | 109 ITEM_SELECTOR = 'article ._5msj' |
| 110 # We scroll further than usual so that Facebook fetches enough items | 110 # We scroll further than usual so that Facebook fetches enough items |
| 111 # (crbug.com/631022) | 111 # (crbug.com/631022) |
| 112 MAIN_PAGE_SCROLL_REPEAT = 1 | 112 MAIN_PAGE_SCROLL_REPEAT = 1 |
| 113 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 113 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 114 TAGS = [story_tags.EMERGING_MARKET] |
| 114 | 115 |
| 115 | 116 |
| 116 class FacebookDesktopStory(_NewsBrowsingStory): | 117 class FacebookDesktopStory(_ArticleBrowsingStory): |
| 117 NAME = 'browse:social:facebook' | 118 NAME = 'browse:social:facebook' |
| 118 URL = 'https://www.facebook.com/rihanna' | 119 URL = 'https://www.facebook.com/rihanna' |
| 119 ITEM_SELECTOR = '._4-eo' | 120 ITEM_SELECTOR = '._4-eo' |
| 120 IS_SINGLE_PAGE_APP = True | 121 IS_SINGLE_PAGE_APP = True |
| 121 # Web-page-replay does not work for this website: | 122 # Web-page-replay does not work for this website: |
| 122 # https://github.com/chromium/web-page-replay/issues/79. | 123 # https://github.com/chromium/web-page-replay/issues/79. |
| 123 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS | 124 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| 124 | 125 |
| 125 | 126 |
| 126 class FlipboardMobileStory(_NewsBrowsingStory): | 127 class InstagramMobileStory(_ArticleBrowsingStory): |
| 128 NAME = 'browse:social:instagram' |
| 129 URL = 'https://www.instagram.com/badgalriri/' |
| 130 ITEM_SELECTOR = '[class=\\"_8mlbc _vbtk2 _t5r8b\\"]' |
| 131 ITEMS_TO_VISIT = 8 |
| 132 |
| 133 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 134 TAGS = [story_tags.EMERGING_MARKET] |
| 135 |
| 136 def _WaitForNavigation(self, action_runner): |
| 137 action_runner.WaitForElement(text='load more comments') |
| 138 |
| 139 def _NavigateBack(self, action_runner): |
| 140 action_runner.NavigateBack() |
| 141 |
| 142 |
| 143 class FlipboardMobileStory(_ArticleBrowsingStory): |
| 127 NAME = 'browse:news:flipboard' | 144 NAME = 'browse:news:flipboard' |
| 128 URL = 'https://flipboard.com/explore' | 145 URL = 'https://flipboard.com/explore' |
| 129 IS_SINGLE_PAGE_APP = True | 146 IS_SINGLE_PAGE_APP = True |
| 130 ITEM_SELECTOR = '.grad-top' | 147 ITEM_SELECTOR = '.grad-top' |
| 131 ITEM_SCROLL_REPEAT = 4 | 148 ITEM_SCROLL_REPEAT = 4 |
| 132 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 149 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 133 | 150 |
| 134 | 151 |
| 135 class FlipboardDesktopStory(_NewsBrowsingStory): | 152 class FlipboardDesktopStory(_ArticleBrowsingStory): |
| 136 NAME = 'browse:news:flipboard' | 153 NAME = 'browse:news:flipboard' |
| 137 URL = 'https://flipboard.com/explore' | 154 URL = 'https://flipboard.com/explore' |
| 138 IS_SINGLE_PAGE_APP = True | 155 IS_SINGLE_PAGE_APP = True |
| 139 ITEM_SELECTOR = '.cover-image' | 156 ITEM_SELECTOR = '.cover-image' |
| 140 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 157 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 141 | 158 |
| 142 | 159 |
| 143 # crbug.com/657665 for win and mac | 160 # crbug.com/657665 for win and mac |
| 144 @decorators.Disabled('win', 'mac') | 161 @decorators.Disabled('win', 'mac') |
| 145 class HackerNewsStory(_NewsBrowsingStory): | 162 class HackerNewsStory(_ArticleBrowsingStory): |
| 146 NAME = 'browse:news:hackernews' | 163 NAME = 'browse:news:hackernews' |
| 147 URL = 'https://news.ycombinator.com' | 164 URL = 'https://news.ycombinator.com' |
| 148 ITEM_SELECTOR = '.athing .title > a' | 165 ITEM_SELECTOR = '.athing .title > a' |
| 149 | 166 |
| 150 | 167 |
| 151 class NytimesMobileStory(_NewsBrowsingStory): | 168 class NytimesMobileStory(_ArticleBrowsingStory): |
| 152 """The third top website in http://www.alexa.com/topsites/category/News""" | 169 """The third top website in http://www.alexa.com/topsites/category/News""" |
| 153 NAME = 'browse:news:nytimes' | 170 NAME = 'browse:news:nytimes' |
| 154 URL = 'http://mobile.nytimes.com' | 171 URL = 'http://mobile.nytimes.com' |
| 155 ITEM_SELECTOR = '.sfgAsset-link' | 172 ITEM_SELECTOR = '.sfgAsset-link' |
| 156 # Visiting more items causes OOM. | 173 # Visiting more items causes OOM. |
| 157 ITEMS_TO_VISIT = 2 | 174 ITEMS_TO_VISIT = 2 |
| 158 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 175 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 159 | 176 |
| 160 | 177 |
| 161 class NytimesDesktopStory(_NewsBrowsingStory): | 178 class NytimesDesktopStory(_ArticleBrowsingStory): |
| 162 """The third top website in http://www.alexa.com/topsites/category/News""" | 179 """The third top website in http://www.alexa.com/topsites/category/News""" |
| 163 NAME = 'browse:news:nytimes' | 180 NAME = 'browse:news:nytimes' |
| 164 URL = 'http://www.nytimes.com' | 181 URL = 'http://www.nytimes.com' |
| 165 ITEM_SELECTOR = '.story-heading > a' | 182 ITEM_SELECTOR = '.story-heading > a' |
| 166 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 183 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 167 | 184 |
| 168 | 185 |
| 169 # Desktop qq.com opens a news item in a separate tab, for which the back button | 186 # Desktop qq.com opens a news item in a separate tab, for which the back button |
| 170 # does not work. | 187 # does not work. |
| 171 class QqMobileStory(_NewsBrowsingStory): | 188 class QqMobileStory(_ArticleBrowsingStory): |
| 172 NAME = 'browse:news:qq' | 189 NAME = 'browse:news:qq' |
| 173 URL = 'http://news.qq.com' | 190 URL = 'http://news.qq.com' |
| 174 ITEM_SELECTOR = '.list .full a' | 191 ITEM_SELECTOR = '.list .full a' |
| 175 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 192 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 176 TAGS = [story_tags.INTERNATIONAL] | 193 TAGS = [story_tags.INTERNATIONAL] |
| 177 | 194 |
| 178 | 195 |
| 179 class RedditDesktopStory(_NewsBrowsingStory): | 196 class RedditDesktopStory(_ArticleBrowsingStory): |
| 180 """The top website in http://www.alexa.com/topsites/category/News""" | 197 """The top website in http://www.alexa.com/topsites/category/News""" |
| 181 NAME = 'browse:news:reddit' | 198 NAME = 'browse:news:reddit' |
| 182 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' | 199 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| 183 ITEM_SELECTOR = '.thing .title > a' | 200 ITEM_SELECTOR = '.thing .title > a' |
| 184 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 201 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 185 | 202 |
| 186 | 203 |
| 187 class RedditMobileStory(_NewsBrowsingStory): | 204 class RedditMobileStory(_ArticleBrowsingStory): |
| 188 """The top website in http://www.alexa.com/topsites/category/News""" | 205 """The top website in http://www.alexa.com/topsites/category/News""" |
| 189 NAME = 'browse:news:reddit' | 206 NAME = 'browse:news:reddit' |
| 190 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' | 207 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| 191 IS_SINGLE_PAGE_APP = True | 208 IS_SINGLE_PAGE_APP = True |
| 192 ITEM_SELECTOR = '.PostHeader__post-title-line' | 209 ITEM_SELECTOR = '.PostHeader__post-title-line' |
| 193 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 210 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 194 | 211 |
| 195 | 212 |
| 196 class TwitterMobileStory(_NewsBrowsingStory): | 213 class TwitterMobileStory(_ArticleBrowsingStory): |
| 197 NAME = 'browse:social:twitter' | 214 NAME = 'browse:social:twitter' |
| 198 URL = 'https://www.twitter.com/nasa' | 215 URL = 'https://www.twitter.com/nasa' |
| 199 ITEM_SELECTOR = '.Tweet-text' | 216 ITEM_SELECTOR = '.Tweet-text' |
| 200 CONTAINER_SELECTOR = '.NavigationSheet' | 217 CONTAINER_SELECTOR = '.NavigationSheet' |
| 201 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 218 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 202 | 219 |
| 203 | 220 |
| 204 @decorators.Disabled('win') # crbug.com/662971 | 221 @decorators.Disabled('win') # crbug.com/662971 |
| 205 class TwitterDesktopStory(_NewsBrowsingStory): | 222 class TwitterDesktopStory(_ArticleBrowsingStory): |
| 206 NAME = 'browse:social:twitter' | 223 NAME = 'browse:social:twitter' |
| 207 URL = 'https://www.twitter.com/nasa' | 224 URL = 'https://www.twitter.com/nasa' |
| 208 IS_SINGLE_PAGE_APP = True | 225 IS_SINGLE_PAGE_APP = True |
| 209 ITEM_SELECTOR = '.tweet-text' | 226 ITEM_SELECTOR = '.tweet-text' |
| 210 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 227 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 211 | 228 |
| 212 | 229 |
| 213 class WashingtonPostMobileStory(_NewsBrowsingStory): | 230 class WashingtonPostMobileStory(_ArticleBrowsingStory): |
| 214 """Progressive website""" | 231 """Progressive website""" |
| 215 NAME = 'browse:news:washingtonpost' | 232 NAME = 'browse:news:washingtonpost' |
| 216 URL = 'https://www.washingtonpost.com/pwa' | 233 URL = 'https://www.washingtonpost.com/pwa' |
| 217 IS_SINGLE_PAGE_APP = True | 234 IS_SINGLE_PAGE_APP = True |
| 218 ITEM_SELECTOR = '.hed > a' | 235 ITEM_SELECTOR = '.hed > a' |
| 219 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 236 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 220 _CLOSE_BUTTON_SELECTOR = '.close' | 237 _CLOSE_BUTTON_SELECTOR = '.close' |
| 221 | 238 |
| 222 def _DidLoadDocument(self, action_runner): | 239 def _DidLoadDocument(self, action_runner): |
| 223 # Close the popup window. On Nexus 9 (and probably other tables) the popup | 240 # Close the popup window. On Nexus 9 (and probably other tables) the popup |
| 224 # window does not have a "Close" button, instead it has only a "Send link | 241 # window does not have a "Close" button, instead it has only a "Send link |
| 225 # to phone" button. So on tablets we run with the popup window open. The | 242 # to phone" button. So on tablets we run with the popup window open. The |
| 226 # popup is transparent, so this is mostly an aesthetical issue. | 243 # popup is transparent, so this is mostly an aesthetical issue. |
| 227 has_button = action_runner.EvaluateJavaScript( | 244 has_button = action_runner.EvaluateJavaScript( |
| 228 '!!document.querySelector({{ selector }})', | 245 '!!document.querySelector({{ selector }})', |
| 229 selector=self._CLOSE_BUTTON_SELECTOR) | 246 selector=self._CLOSE_BUTTON_SELECTOR) |
| 230 if has_button: | 247 if has_button: |
| 231 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) | 248 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) |
| 232 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) | 249 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) |
| 233 | 250 |
| 234 | 251 |
| 235 ############################################################################## | 252 ############################################################################## |
| 236 # Search browsing stories. | 253 # Search browsing stories. |
| 237 ############################################################################## | 254 ############################################################################## |
| 238 | 255 |
| 239 | 256 |
| 240 @decorators.Disabled('win') # crbug.com/673775 | 257 @decorators.Disabled('win') # crbug.com/673775 |
| 241 class GoogleDesktopStory(_NewsBrowsingStory): | 258 class GoogleDesktopStory(_ArticleBrowsingStory): |
| 242 """ | 259 """ |
| 243 A typical google search story: | 260 A typical google search story: |
| 244 _ Start at https://www.google.com/search?q=flower | 261 _ Start at https://www.google.com/search?q=flower |
| 245 _ Click on the wikipedia link & navigate to | 262 _ Click on the wikipedia link & navigate to |
| 246 https://en.wikipedia.org/wiki/Flower | 263 https://en.wikipedia.org/wiki/Flower |
| 247 _ Scroll down the wikipedia page about flower. | 264 _ Scroll down the wikipedia page about flower. |
| 248 _ Back to the search main page. | 265 _ Back to the search main page. |
| 249 _ Refine the search query to 'flower delivery'. | 266 _ Refine the search query to 'flower delivery'. |
| 250 _ Scroll down the page. | 267 _ Scroll down the page. |
| 251 _ Click the next page result of 'flower delivery'. | 268 _ Click the next page result of 'flower delivery'. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 282 | 299 |
| 283 # Scroll down & click next search result page. | 300 # Scroll down & click next search result page. |
| 284 action_runner.Wait(2) | 301 action_runner.Wait(2) |
| 285 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 302 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 286 action_runner.Wait(2) | 303 action_runner.Wait(2) |
| 287 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 304 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 288 action_runner.Wait(2) | 305 action_runner.Wait(2) |
| 289 action_runner.ScrollPage() | 306 action_runner.ScrollPage() |
| 290 | 307 |
| 291 | 308 |
| 292 class GoogleIndiaDesktopStory(_NewsBrowsingStory): | 309 class GoogleIndiaDesktopStory(_ArticleBrowsingStory): |
| 293 """ | 310 """ |
| 294 A typical google search story in India: | 311 A typical google search story in India: |
| 295 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` | 312 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` |
| 296 2. Scroll down the page. | 313 2. Scroll down the page. |
| 297 3. Refine the query & click search box, which navigates to | 314 3. Refine the query & click search box, which navigates to |
| 298 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 | 315 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 |
| 299 4. Scroll down the page. | 316 4. Scroll down the page. |
| 300 5. Click the next page result | 317 5. Click the next page result |
| 301 6. Scroll the search result page. | 318 6. Scroll the search result page. |
| 302 | 319 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 386 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
| 370 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) | 387 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) |
| 371 | 388 |
| 372 | 389 |
| 373 class ImgurMobileStory(_MediaBrowsingStory): | 390 class ImgurMobileStory(_MediaBrowsingStory): |
| 374 NAME = 'browse:media:imgur' | 391 NAME = 'browse:media:imgur' |
| 375 URL = 'http://imgur.com/gallery/5UlBN' | 392 URL = 'http://imgur.com/gallery/5UlBN' |
| 376 ITEM_SELECTOR = '.Navbar-customAction' | 393 ITEM_SELECTOR = '.Navbar-customAction' |
| 377 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 394 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 378 IS_SINGLE_PAGE_APP = True | 395 IS_SINGLE_PAGE_APP = True |
| 396 TAGS = [story_tags.EMERGING_MARKET] |
| 379 | 397 |
| 380 | 398 |
| 381 # crbug.com/704197 for win and mac | 399 # crbug.com/704197 for win and mac |
| 382 @decorators.Disabled('win', 'mac') | 400 @decorators.Disabled('win', 'mac') |
| 383 class ImgurDesktopStory(_MediaBrowsingStory): | 401 class ImgurDesktopStory(_MediaBrowsingStory): |
| 384 NAME = 'browse:media:imgur' | 402 NAME = 'browse:media:imgur' |
| 385 URL = 'http://imgur.com/gallery/5UlBN' | 403 URL = 'http://imgur.com/gallery/5UlBN' |
| 386 ITEM_SELECTOR = '.navNext' | 404 ITEM_SELECTOR = '.navNext' |
| 387 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 405 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 388 IS_SINGLE_PAGE_APP = True | 406 IS_SINGLE_PAGE_APP = True |
| 389 | 407 |
| 390 | 408 |
| 391 class YouTubeMobileStory(_MediaBrowsingStory): | 409 class YouTubeMobileStory(_MediaBrowsingStory): |
| 392 NAME = 'browse:media:youtube' | 410 NAME = 'browse:media:youtube' |
| 393 URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' | 411 URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| 394 ITEM_SELECTOR = '._mhgb > a' | 412 ITEM_SELECTOR = '._mhgb > a' |
| 395 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 413 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 396 IS_SINGLE_PAGE_APP = True | 414 IS_SINGLE_PAGE_APP = True |
| 397 ITEM_SELECTOR_INDEX = 3 | 415 ITEM_SELECTOR_INDEX = 3 |
| 398 TAGS = [story_tags.JAVASCRIPT_HEAVY] | 416 TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| 417 TAGS = [story_tags.EMERGING_MARKET] |
| 399 | 418 |
| 400 | 419 |
| 401 class YouTubeDesktopStory(_MediaBrowsingStory): | 420 class YouTubeDesktopStory(_MediaBrowsingStory): |
| 402 NAME = 'browse:media:youtube' | 421 NAME = 'browse:media:youtube' |
| 403 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' | 422 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| 404 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' | 423 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' |
| 405 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 424 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 406 IS_SINGLE_PAGE_APP = True | 425 IS_SINGLE_PAGE_APP = True |
| 407 # A longer view time allows videos to load and play. | 426 # A longer view time allows videos to load and play. |
| 408 ITEM_VIEW_TIME_IN_SECONDS = 5 | 427 ITEM_VIEW_TIME_IN_SECONDS = 5 |
| 409 ITEMS_TO_VISIT = 8 | 428 ITEMS_TO_VISIT = 8 |
| 410 ITEM_SELECTOR_INDEX = 3 | 429 ITEM_SELECTOR_INDEX = 3 |
| 411 PLATFORM_SPECIFIC = True | 430 PLATFORM_SPECIFIC = True |
| 412 TAGS = [story_tags.JAVASCRIPT_HEAVY] | 431 TAGS = [story_tags.JAVASCRIPT_HEAVY] |
| 413 | 432 |
| 414 | 433 |
| 415 class FacebookPhotosMobileStory(_MediaBrowsingStory): | 434 class FacebookPhotosMobileStory(_MediaBrowsingStory): |
| 416 NAME = 'browse:media:facebook_photos' | 435 NAME = 'browse:media:facebook_photos' |
| 417 URL = ( | 436 URL = ( |
| 418 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/1
0153911739606676/?type=3&source=54&ref=page_internal') | 437 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/1
0153911739606676/?type=3&source=54&ref=page_internal') |
| 419 ITEM_SELECTOR = '._57-r.touchable' | 438 ITEM_SELECTOR = '._57-r.touchable' |
| 420 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 439 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 421 IS_SINGLE_PAGE_APP = True | 440 IS_SINGLE_PAGE_APP = True |
| 422 ITEM_SELECTOR_INDEX = 0 | 441 ITEM_SELECTOR_INDEX = 0 |
| 442 TAGS = [story_tags.EMERGING_MARKET] |
| 423 | 443 |
| 424 | 444 |
| 425 class FacebookPhotosDesktopStory(_MediaBrowsingStory): | 445 class FacebookPhotosDesktopStory(_MediaBrowsingStory): |
| 426 NAME = 'browse:media:facebook_photos' | 446 NAME = 'browse:media:facebook_photos' |
| 427 URL = ( | 447 URL = ( |
| 428 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675
/10153911739606676/?type=3&theater') | 448 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675
/10153911739606676/?type=3&theater') |
| 429 ITEM_SELECTOR = '.snowliftPager.next' | 449 ITEM_SELECTOR = '.snowliftPager.next' |
| 430 # Recording currently does not work. The page gets stuck in the | 450 # Recording currently does not work. The page gets stuck in the |
| 431 # theater viewer. | 451 # theater viewer. |
| 432 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS | 452 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 inner_save_function = 'document.querySelector(".nameAndIcons")' | 496 inner_save_function = 'document.querySelector(".nameAndIcons")' |
| 477 action_runner.WaitForElement(element_function=inner_save_function) | 497 action_runner.WaitForElement(element_function=inner_save_function) |
| 478 action_runner.ClickElement(element_function=inner_save_function) | 498 action_runner.ClickElement(element_function=inner_save_function) |
| 479 action_runner.Wait(1) # Wait to make navigation realistic. | 499 action_runner.Wait(1) # Wait to make navigation realistic. |
| 480 | 500 |
| 481 # Close selection. | 501 # Close selection. |
| 482 x_element_function = ('document.querySelector(' | 502 x_element_function = ('document.querySelector(' |
| 483 '".Button.borderless.close.visible")') | 503 '".Button.borderless.close.visible")') |
| 484 action_runner.ClickElement(element_function=x_element_function) | 504 action_runner.ClickElement(element_function=x_element_function) |
| 485 action_runner.Wait(1) # Wait to make navigation realistic. | 505 action_runner.Wait(1) # Wait to make navigation realistic. |
| 506 |
| 507 |
| 508 ############################################################################## |
| 509 # Emerging market browsing stories. |
| 510 ############################################################################## |
| 511 |
| 512 |
| 513 @decorators.Disabled('android') # crbug.com/708300. |
| 514 class BrowseFlipKartMobileStory(_ArticleBrowsingStory): |
| 515 NAME = 'browse:shopping:flipkart' |
| 516 URL = 'https://flipkart.com/search?q=Sunglasses' |
| 517 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 518 TAGS = [story_tags.EMERGING_MARKET] |
| 519 |
| 520 ITEM_SELECTOR = '[style=\\"background-image: none;\\"]' |
| 521 BACK_SELECTOR = '._3NH1qf' |
| 522 ITEMS_TO_VISIT = 4 |
| 523 IS_SINGLE_PAGE_APP = True |
| 524 |
| 525 def _WaitForNavigation(self, action_runner): |
| 526 action_runner.WaitForElement(text='Details') |
| 527 |
| 528 def _NavigateBack(self, action_runner): |
| 529 action_runner.ClickElement(selector=self.BACK_SELECTOR) |
| 530 action_runner.WaitForElement(text="Sunglasses") |
| 531 |
| 532 |
| 533 class BrowseAmazonMobileStory(_ArticleBrowsingStory): |
| 534 NAME = 'browse:shopping:amazon' |
| 535 URL = 'https://www.amazon.co.in/s/?field-keywords=Mobile' |
| 536 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 537 TAGS = [story_tags.EMERGING_MARKET] |
| 538 |
| 539 ITEM_SELECTOR = '.aw-search-results' |
| 540 ITEMS_TO_VISIT = 4 |
| 541 |
| 542 |
| 543 class BrowseLazadaMobileStory(_ArticleBrowsingStory): |
| 544 NAME = 'browse:shopping:lazada' |
| 545 URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch' |
| 546 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 547 TAGS = [story_tags.EMERGING_MARKET] |
| 548 |
| 549 ITEM_SELECTOR = '.merchandise__link' |
| 550 ITEMS_TO_VISIT = 1 |
| 551 |
| 552 |
| 553 class BrowseAvitoMobileStory(_ArticleBrowsingStory): |
| 554 NAME = 'browse:shopping:avito' |
| 555 URL = 'https://www.avito.ru/rossiya' |
| 556 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 557 TAGS = [story_tags.EMERGING_MARKET] |
| 558 |
| 559 ITEM_SELECTOR = '.item-link' |
| 560 ITEMS_TO_VISIT = 4 |
| 561 |
| 562 |
| 563 class BrowseTOIMobileStory(_ArticleBrowsingStory): |
| 564 NAME = 'browse:news:toi' |
| 565 URL = 'http://m.timesofindia.com' |
| 566 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 567 TAGS = [story_tags.EMERGING_MARKET] |
| 568 |
| 569 ITEMS_TO_VISIT = 4 |
| 570 ITEM_SELECTOR = '.dummy-img' |
| 571 |
| 572 |
| 573 class BrowseGloboMobileStory(_ArticleBrowsingStory): |
| 574 NAME = 'browse:news:globo' |
| 575 URL = 'http://www.globo.com' |
| 576 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 577 TAGS = [story_tags.EMERGING_MARKET] |
| 578 |
| 579 ITEMS_TO_VISIT = 4 |
| 580 ITEM_SELECTOR = '.hui-premium__title' |
| 581 |
| 582 |
| 583 class BrowseCricBuzzMobileStory(_ArticleBrowsingStory): |
| 584 NAME = 'browse:news:cricbuzz' |
| 585 URL = 'http://m.cricbuzz.com' |
| 586 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 587 TAGS = [story_tags.EMERGING_MARKET] |
| 588 |
| 589 ITEMS_TO_VISIT = 3 |
| 590 ITEM_SELECTOR = '.list-content' |
| 591 |
| 592 |
| 593 |
| 594 ############################################################################## |
| 595 # Maps browsing stories. |
| 596 ############################################################################## |
| 597 |
| 598 |
| 599 class GoogleMapsMobileStory(system_health_story.SystemHealthStory): |
| 600 """Story that browses google maps mobile page |
| 601 |
| 602 This story searches for nearby restaurants on google maps website and finds |
| 603 directions to a chosen restaurant from search results. |
| 604 """ |
| 605 NAME = 'browse:tools:maps' |
| 606 URL = 'https://maps.google.com/' |
| 607 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 608 TAGS = [story_tags.EMERGING_MARKET] |
| 609 |
| 610 _MAPS_SEARCH_BOX_SELECTOR = '.ml-searchbox-placeholder' |
| 611 _RESTAURANTS_LOADED = '.ml-panes-categorical-list-results' |
| 612 _SEARCH_NEW_AREA_SELECTOR = '.ml-reissue-search-button-inner' |
| 613 _RESTAURANTS_LINK = '.ml-entity-list-item-info' |
| 614 _DIRECTIONS_LINK = '[class="ml-button ml-inner-button-directions-fab"]' |
| 615 _DIRECTIONS_LOADED = ('[class="ml-fab-inner ' |
| 616 'ml-button ml-button-navigation-fab"]') |
| 617 _MAP_LAYER = '.ml-map' |
| 618 |
| 619 def _DidLoadDocument(self, action_runner): |
| 620 # Submit search query. |
| 621 self._ClickLink(self._MAPS_SEARCH_BOX_SELECTOR, action_runner) |
| 622 action_runner.EnterText('restaurants near me') |
| 623 action_runner.PressKey('Return') |
| 624 action_runner.WaitForElement(selector=self._RESTAURANTS_LOADED) |
| 625 action_runner.WaitForNetworkQuiescence() |
| 626 action_runner.Wait(4) # User looking at restaurants |
| 627 |
| 628 # Open the restaurant list and select the first. |
| 629 self._ClickLink(self._RESTAURANTS_LOADED, action_runner) |
| 630 action_runner.WaitForElement(selector=self._RESTAURANTS_LINK) |
| 631 action_runner.Wait(3) # User reads about restaurant |
| 632 self._ClickLink(self._RESTAURANTS_LINK, action_runner) |
| 633 action_runner.Wait(1) # Reading description |
| 634 |
| 635 # Open directions to the restaurant from Google. |
| 636 self._ClickLink(self._DIRECTIONS_LINK, action_runner) |
| 637 action_runner.Wait(0.5) |
| 638 action_runner.EnterText('Google Mountain View') |
| 639 action_runner.PressKey('Return') |
| 640 action_runner.WaitForElement(selector=self._DIRECTIONS_LOADED) |
| 641 action_runner.WaitForNetworkQuiescence() |
| 642 action_runner.Wait(2) # Seeing direction |
| 643 |
| 644 def _ClickLink(self, selector, action_runner): |
| 645 action_runner.WaitForElement(selector=selector) |
| 646 action_runner.ClickElement(selector=selector) |
| OLD | NEW |