Chromium Code Reviews| 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 IS_SINGLE_PAGE_APP = True | |
| 133 | |
| 134 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 135 TAGS = [story_tags.EMERGING_MARKET] | |
| 136 | |
| 137 | |
| 138 class FlipboardMobileStory(_ArticleBrowsingStory): | |
| 127 NAME = 'browse:news:flipboard' | 139 NAME = 'browse:news:flipboard' |
| 128 URL = 'https://flipboard.com/explore' | 140 URL = 'https://flipboard.com/explore' |
| 129 IS_SINGLE_PAGE_APP = True | 141 IS_SINGLE_PAGE_APP = True |
| 130 ITEM_SELECTOR = '.grad-top' | 142 ITEM_SELECTOR = '.grad-top' |
| 131 ITEM_SCROLL_REPEAT = 4 | 143 ITEM_SCROLL_REPEAT = 4 |
| 132 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 144 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 133 | 145 |
| 134 @classmethod | 146 @classmethod |
| 135 def ShouldDisable(cls, possible_browser): | 147 def ShouldDisable(cls, possible_browser): |
| 136 return possible_browser.platform.IsSvelte() # crbug.com/668097 | 148 return possible_browser.platform.IsSvelte() # crbug.com/668097 |
| 137 | 149 |
| 138 | 150 |
| 139 class FlipboardDesktopStory(_NewsBrowsingStory): | 151 class FlipboardDesktopStory(_ArticleBrowsingStory): |
| 140 NAME = 'browse:news:flipboard' | 152 NAME = 'browse:news:flipboard' |
| 141 URL = 'https://flipboard.com/explore' | 153 URL = 'https://flipboard.com/explore' |
| 142 IS_SINGLE_PAGE_APP = True | 154 IS_SINGLE_PAGE_APP = True |
| 143 ITEM_SELECTOR = '.cover-image' | 155 ITEM_SELECTOR = '.cover-image' |
| 144 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 156 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 145 | 157 |
| 146 | 158 |
| 147 # crbug.com/657665 for win and mac | 159 # crbug.com/657665 for win and mac |
| 148 @decorators.Disabled('win', 'mac') | 160 @decorators.Disabled('win', 'mac') |
| 149 class HackerNewsStory(_NewsBrowsingStory): | 161 class HackerNewsStory(_ArticleBrowsingStory): |
| 150 NAME = 'browse:news:hackernews' | 162 NAME = 'browse:news:hackernews' |
| 151 URL = 'https://news.ycombinator.com' | 163 URL = 'https://news.ycombinator.com' |
| 152 ITEM_SELECTOR = '.athing .title > a' | 164 ITEM_SELECTOR = '.athing .title > a' |
| 153 | 165 |
| 154 | 166 |
| 155 class NytimesMobileStory(_NewsBrowsingStory): | 167 class NytimesMobileStory(_ArticleBrowsingStory): |
| 156 """The third top website in http://www.alexa.com/topsites/category/News""" | 168 """The third top website in http://www.alexa.com/topsites/category/News""" |
| 157 NAME = 'browse:news:nytimes' | 169 NAME = 'browse:news:nytimes' |
| 158 URL = 'http://mobile.nytimes.com' | 170 URL = 'http://mobile.nytimes.com' |
| 159 ITEM_SELECTOR = '.sfgAsset-link' | 171 ITEM_SELECTOR = '.sfgAsset-link' |
| 160 # Visiting more items causes OOM. | 172 # Visiting more items causes OOM. |
| 161 ITEMS_TO_VISIT = 2 | 173 ITEMS_TO_VISIT = 2 |
| 162 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 174 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 163 | 175 |
| 164 | 176 |
| 165 class NytimesDesktopStory(_NewsBrowsingStory): | 177 class NytimesDesktopStory(_ArticleBrowsingStory): |
| 166 """The third top website in http://www.alexa.com/topsites/category/News""" | 178 """The third top website in http://www.alexa.com/topsites/category/News""" |
| 167 NAME = 'browse:news:nytimes' | 179 NAME = 'browse:news:nytimes' |
| 168 URL = 'http://www.nytimes.com' | 180 URL = 'http://www.nytimes.com' |
| 169 ITEM_SELECTOR = '.story-heading > a' | 181 ITEM_SELECTOR = '.story-heading > a' |
| 170 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 182 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 171 | 183 |
| 172 | 184 |
| 173 # Desktop qq.com opens a news item in a separate tab, for which the back button | 185 # Desktop qq.com opens a news item in a separate tab, for which the back button |
| 174 # does not work. | 186 # does not work. |
| 175 class QqMobileStory(_NewsBrowsingStory): | 187 class QqMobileStory(_ArticleBrowsingStory): |
| 176 NAME = 'browse:news:qq' | 188 NAME = 'browse:news:qq' |
| 177 URL = 'http://news.qq.com' | 189 URL = 'http://news.qq.com' |
| 178 ITEM_SELECTOR = '.list .full a' | 190 ITEM_SELECTOR = '.list .full a' |
| 179 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 191 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 180 TAGS = [story_tags.INTERNATIONAL] | 192 TAGS = [story_tags.INTERNATIONAL] |
| 181 | 193 |
| 182 | 194 |
| 183 class RedditDesktopStory(_NewsBrowsingStory): | 195 class RedditDesktopStory(_ArticleBrowsingStory): |
| 184 """The top website in http://www.alexa.com/topsites/category/News""" | 196 """The top website in http://www.alexa.com/topsites/category/News""" |
| 185 NAME = 'browse:news:reddit' | 197 NAME = 'browse:news:reddit' |
| 186 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' | 198 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| 187 ITEM_SELECTOR = '.thing .title > a' | 199 ITEM_SELECTOR = '.thing .title > a' |
| 188 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 200 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 189 | 201 |
| 190 | 202 |
| 191 class RedditMobileStory(_NewsBrowsingStory): | 203 class RedditMobileStory(_ArticleBrowsingStory): |
| 192 """The top website in http://www.alexa.com/topsites/category/News""" | 204 """The top website in http://www.alexa.com/topsites/category/News""" |
| 193 NAME = 'browse:news:reddit' | 205 NAME = 'browse:news:reddit' |
| 194 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' | 206 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' |
| 195 IS_SINGLE_PAGE_APP = True | 207 IS_SINGLE_PAGE_APP = True |
| 196 ITEM_SELECTOR = '.PostHeader__post-title-line' | 208 ITEM_SELECTOR = '.PostHeader__post-title-line' |
| 197 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 209 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 198 | 210 |
| 199 | 211 |
| 200 class TwitterMobileStory(_NewsBrowsingStory): | 212 class TwitterMobileStory(_ArticleBrowsingStory): |
| 201 NAME = 'browse:social:twitter' | 213 NAME = 'browse:social:twitter' |
| 202 URL = 'https://www.twitter.com/nasa' | 214 URL = 'https://www.twitter.com/nasa' |
| 203 ITEM_SELECTOR = '.Tweet-text' | 215 ITEM_SELECTOR = '.Tweet-text' |
| 204 CONTAINER_SELECTOR = '.NavigationSheet' | 216 CONTAINER_SELECTOR = '.NavigationSheet' |
| 205 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 217 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 206 | 218 |
| 207 | 219 |
| 208 @decorators.Disabled('win') # crbug.com/662971 | 220 @decorators.Disabled('win') # crbug.com/662971 |
| 209 class TwitterDesktopStory(_NewsBrowsingStory): | 221 class TwitterDesktopStory(_ArticleBrowsingStory): |
| 210 NAME = 'browse:social:twitter' | 222 NAME = 'browse:social:twitter' |
| 211 URL = 'https://www.twitter.com/nasa' | 223 URL = 'https://www.twitter.com/nasa' |
| 212 IS_SINGLE_PAGE_APP = True | 224 IS_SINGLE_PAGE_APP = True |
| 213 ITEM_SELECTOR = '.tweet-text' | 225 ITEM_SELECTOR = '.tweet-text' |
| 214 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 226 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 215 | 227 |
| 216 | 228 |
| 217 class WashingtonPostMobileStory(_NewsBrowsingStory): | 229 class WashingtonPostMobileStory(_ArticleBrowsingStory): |
| 218 """Progressive website""" | 230 """Progressive website""" |
| 219 NAME = 'browse:news:washingtonpost' | 231 NAME = 'browse:news:washingtonpost' |
| 220 URL = 'https://www.washingtonpost.com/pwa' | 232 URL = 'https://www.washingtonpost.com/pwa' |
| 221 IS_SINGLE_PAGE_APP = True | 233 IS_SINGLE_PAGE_APP = True |
| 222 ITEM_SELECTOR = '.hed > a' | 234 ITEM_SELECTOR = '.hed > a' |
| 223 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 235 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
| 224 _CLOSE_BUTTON_SELECTOR = '.close' | 236 _CLOSE_BUTTON_SELECTOR = '.close' |
| 225 | 237 |
| 226 def _DidLoadDocument(self, action_runner): | 238 def _DidLoadDocument(self, action_runner): |
| 227 # Close the popup window. On Nexus 9 (and probably other tables) the popup | 239 # Close the popup window. On Nexus 9 (and probably other tables) the popup |
| 228 # window does not have a "Close" button, instead it has only a "Send link | 240 # window does not have a "Close" button, instead it has only a "Send link |
| 229 # to phone" button. So on tablets we run with the popup window open. The | 241 # to phone" button. So on tablets we run with the popup window open. The |
| 230 # popup is transparent, so this is mostly an aesthetical issue. | 242 # popup is transparent, so this is mostly an aesthetical issue. |
| 231 has_button = action_runner.EvaluateJavaScript( | 243 has_button = action_runner.EvaluateJavaScript( |
| 232 '!!document.querySelector({{ selector }})', | 244 '!!document.querySelector({{ selector }})', |
| 233 selector=self._CLOSE_BUTTON_SELECTOR) | 245 selector=self._CLOSE_BUTTON_SELECTOR) |
| 234 if has_button: | 246 if has_button: |
| 235 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) | 247 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) |
| 236 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) | 248 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) |
| 237 | 249 |
| 238 | 250 |
| 239 ############################################################################## | 251 ############################################################################## |
| 240 # Search browsing stories. | 252 # Search browsing stories. |
| 241 ############################################################################## | 253 ############################################################################## |
| 242 | 254 |
| 243 | 255 |
| 244 @decorators.Disabled('win') # crbug.com/673775 | 256 @decorators.Disabled('win') # crbug.com/673775 |
| 245 class GoogleDesktopStory(_NewsBrowsingStory): | 257 class GoogleDesktopStory(_ArticleBrowsingStory): |
| 246 """ | 258 """ |
| 247 A typical google search story: | 259 A typical google search story: |
| 248 _ Start at https://www.google.com/search?q=flower | 260 _ Start at https://www.google.com/search?q=flower |
| 249 _ Click on the wikipedia link & navigate to | 261 _ Click on the wikipedia link & navigate to |
| 250 https://en.wikipedia.org/wiki/Flower | 262 https://en.wikipedia.org/wiki/Flower |
| 251 _ Scroll down the wikipedia page about flower. | 263 _ Scroll down the wikipedia page about flower. |
| 252 _ Back to the search main page. | 264 _ Back to the search main page. |
| 253 _ Refine the search query to 'flower delivery'. | 265 _ Refine the search query to 'flower delivery'. |
| 254 _ Scroll down the page. | 266 _ Scroll down the page. |
| 255 _ Click the next page result of 'flower delivery'. | 267 _ Click the next page result of 'flower delivery'. |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 286 | 298 |
| 287 # Scroll down & click next search result page. | 299 # Scroll down & click next search result page. |
| 288 action_runner.Wait(2) | 300 action_runner.Wait(2) |
| 289 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 301 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 290 action_runner.Wait(2) | 302 action_runner.Wait(2) |
| 291 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 303 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 292 action_runner.Wait(2) | 304 action_runner.Wait(2) |
| 293 action_runner.ScrollPage() | 305 action_runner.ScrollPage() |
| 294 | 306 |
| 295 | 307 |
| 296 class GoogleIndiaDesktopStory(_NewsBrowsingStory): | 308 class GoogleIndiaDesktopStory(_ArticleBrowsingStory): |
| 297 """ | 309 """ |
| 298 A typical google search story in India: | 310 A typical google search story in India: |
| 299 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` | 311 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` |
| 300 2. Scroll down the page. | 312 2. Scroll down the page. |
| 301 3. Refine the query & click search box, which navigates to | 313 3. Refine the query & click search box, which navigates to |
| 302 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 | 314 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 |
| 303 4. Scroll down the page. | 315 4. Scroll down the page. |
| 304 5. Click the next page result | 316 5. Click the next page result |
| 305 6. Scroll the search result page. | 317 6. Scroll the search result page. |
| 306 | 318 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 # crbug.com/704197 for win and mac | 397 # crbug.com/704197 for win and mac |
| 386 @decorators.Disabled('win', 'mac') | 398 @decorators.Disabled('win', 'mac') |
| 387 class ImgurDesktopStory(_MediaBrowsingStory): | 399 class ImgurDesktopStory(_MediaBrowsingStory): |
| 388 NAME = 'browse:media:imgur' | 400 NAME = 'browse:media:imgur' |
| 389 URL = 'http://imgur.com/gallery/5UlBN' | 401 URL = 'http://imgur.com/gallery/5UlBN' |
| 390 ITEM_SELECTOR = '.navNext' | 402 ITEM_SELECTOR = '.navNext' |
| 391 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 403 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 392 IS_SINGLE_PAGE_APP = True | 404 IS_SINGLE_PAGE_APP = True |
| 393 | 405 |
| 394 | 406 |
| 395 class YouTubeMobileStory(_MediaBrowsingStory): | |
| 396 NAME = 'browse:media:youtube' | |
| 397 URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' | |
| 398 ITEM_SELECTOR = '._mhgb > a' | |
| 399 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 400 IS_SINGLE_PAGE_APP = True | |
| 401 ITEM_SELECTOR_INDEX = 3 | |
| 402 TAGS = [story_tags.JAVASCRIPT_HEAVY] | |
| 403 | |
| 404 | |
| 405 class YouTubeDesktopStory(_MediaBrowsingStory): | 407 class YouTubeDesktopStory(_MediaBrowsingStory): |
| 406 NAME = 'browse:media:youtube' | 408 NAME = 'browse:media:youtube' |
| 407 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' | 409 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' |
| 408 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' | 410 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' |
| 409 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | 411 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 410 IS_SINGLE_PAGE_APP = True | 412 IS_SINGLE_PAGE_APP = True |
| 411 # A longer view time allows videos to load and play. | 413 # A longer view time allows videos to load and play. |
| 412 ITEM_VIEW_TIME_IN_SECONDS = 5 | 414 ITEM_VIEW_TIME_IN_SECONDS = 5 |
| 413 ITEMS_TO_VISIT = 8 | 415 ITEMS_TO_VISIT = 8 |
| 414 ITEM_SELECTOR_INDEX = 3 | 416 ITEM_SELECTOR_INDEX = 3 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 inner_save_function = 'document.querySelector(".nameAndIcons")' | 482 inner_save_function = 'document.querySelector(".nameAndIcons")' |
| 481 action_runner.WaitForElement(element_function=inner_save_function) | 483 action_runner.WaitForElement(element_function=inner_save_function) |
| 482 action_runner.ClickElement(element_function=inner_save_function) | 484 action_runner.ClickElement(element_function=inner_save_function) |
| 483 action_runner.Wait(1) # Wait to make navigation realistic. | 485 action_runner.Wait(1) # Wait to make navigation realistic. |
| 484 | 486 |
| 485 # Close selection. | 487 # Close selection. |
| 486 x_element_function = ('document.querySelector(' | 488 x_element_function = ('document.querySelector(' |
| 487 '".Button.borderless.close.visible")') | 489 '".Button.borderless.close.visible")') |
| 488 action_runner.ClickElement(element_function=x_element_function) | 490 action_runner.ClickElement(element_function=x_element_function) |
| 489 action_runner.Wait(1) # Wait to make navigation realistic. | 491 action_runner.Wait(1) # Wait to make navigation realistic. |
| 492 | |
| 493 | |
| 494 ############################################################################## | |
| 495 # Emerging market browsing stories. | |
| 496 ############################################################################## | |
| 497 | |
| 498 | |
| 499 class BrowseFlipKartMobileStory(_ArticleBrowsingStory): | |
| 500 NAME = 'browse:shopping:flipkart' | |
| 501 URL = 'https://flipkart.com/search?q=Mobile%20phone' | |
| 502 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 503 TAGS = [story_tags.EMERGING_MARKET] | |
| 504 | |
| 505 ITEM_SELECTOR = '.mEOukM' | |
| 506 BACK_SELECTOR = '._3NH1qf' | |
| 507 ITEMS_TO_VISIT = 4 | |
| 508 IS_SINGLE_PAGE_APP = True | |
| 509 | |
| 510 def _NavigateBack(self, action_runner): | |
| 511 action_runner.ClickElement(selector=self.BACK_SELECTOR) | |
| 512 | |
| 513 | |
| 514 class BrowseAmazonMobileStory(_ArticleBrowsingStory): | |
| 515 NAME = 'browse:shopping:amazon' | |
| 516 URL = 'https://www.amazon.co.in/s/?field-keywords=Mobile' | |
| 517 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 518 TAGS = [story_tags.EMERGING_MARKET] | |
| 519 | |
| 520 ITEM_SELECTOR = '.aw-search-results' | |
| 521 ITEMS_TO_VISIT = 4 | |
| 522 | |
| 523 | |
| 524 class BrowseLazadaMobileStory(_ArticleBrowsingStory): | |
| 525 NAME = 'browse:shopping:lazada' | |
| 526 URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch' | |
| 527 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 528 TAGS = [story_tags.EMERGING_MARKET] | |
| 529 | |
| 530 ITEM_SELECTOR = '.merchandise__link' | |
| 531 ITEMS_TO_VISIT = 1 | |
| 532 | |
| 533 | |
| 534 class BrowseAvitoMobileStory(_ArticleBrowsingStory): | |
| 535 NAME = 'browse:shopping:avito' | |
| 536 URL = 'https://www.avito.ru/rossiya' | |
| 537 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 538 TAGS = [story_tags.EMERGING_MARKET] | |
| 539 | |
| 540 ITEM_SELECTOR = '.item-link' | |
| 541 ITEMS_TO_VISIT = 4 | |
| 542 | |
| 543 | |
| 544 class BrowseTOIMobileStory(_ArticleBrowsingStory): | |
| 545 NAME = 'browse:news:toi' | |
| 546 URL = 'http://m.timesofindia.com' | |
| 547 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 548 TAGS = [story_tags.EMERGING_MARKET] | |
| 549 | |
| 550 ITEMS_TO_VISIT = 4 | |
| 551 ITEM_SELECTOR = '.dummy-img' | |
| 552 | |
| 553 | |
| 554 class BrowseGloboMobileStory(_ArticleBrowsingStory): | |
| 555 NAME = 'browse:news:globo' | |
| 556 URL = 'http://www.globo.com' | |
| 557 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 558 TAGS = [story_tags.EMERGING_MARKET] | |
| 559 | |
| 560 ITEMS_TO_VISIT = 4 | |
| 561 ITEM_SELECTOR = '.hui-premium__title' | |
| 562 | |
| 563 | |
| 564 class BrowseCricBuzzMobileStory(_ArticleBrowsingStory): | |
| 565 NAME = 'browse:news:cricbuzz' | |
| 566 URL = 'http://m.cricbuzz.com' | |
| 567 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 568 TAGS = [story_tags.EMERGING_MARKET] | |
| 569 | |
| 570 ITEMS_TO_VISIT = 3 | |
| 571 ITEM_SELECTOR = '.list-content' | |
| 572 | |
| 573 | |
| 574 | |
| 575 ############################################################################## | |
| 576 # Maps browsing stories. | |
| 577 ############################################################################## | |
| 578 | |
| 579 | |
| 580 class GoogleMapsMobileStory(system_health_story.SystemHealthStory): | |
|
nednguyen
2017/04/11 22:24:10
Same here: please add docstring explain what this
ssid
2017/04/13 21:08:53
Done.
| |
| 581 NAME = 'browse:tools:maps' | |
| 582 URL = 'https://maps.google.com/' | |
| 583 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
| 584 TAGS = [story_tags.EMERGING_MARKET] | |
| 585 | |
| 586 _MAPS_SEARCH_BOX_SELECTOR = '.ml-searchbox-placeholder' | |
| 587 _RESTAURANTS_LOADED = '.ml-panes-categorical-list-results' | |
| 588 _SEARCH_NEW_AREA_SELECTOR = '.ml-reissue-search-button-inner' | |
| 589 _RESTAURANTS_LINK = '.ml-entity-list-item-info' | |
| 590 _DIRECTIONS_LINK = '[class="ml-button ml-inner-button-directions-fab"]' | |
| 591 _DIRECTIONS_LOADED = ('[class="ml-fab-inner ' | |
| 592 'ml-button ml-button-navigation-fab"]') | |
| 593 _MAP_LAYER = '.ml-map' | |
| 594 | |
| 595 def _DidLoadDocument(self, action_runner): | |
| 596 # Submit search query. | |
| 597 self._ClickLink(self._MAPS_SEARCH_BOX_SELECTOR, action_runner) | |
| 598 action_runner.EnterText('restaurants near me') | |
| 599 action_runner.PressKey('Return') | |
| 600 action_runner.WaitForElement(selector=self._RESTAURANTS_LOADED) | |
| 601 action_runner.WaitForNetworkQuiescence() | |
| 602 action_runner.Wait(4) # User looking at restaurants | |
| 603 | |
| 604 # Open the restaurant list and select the first. | |
| 605 self._ClickLink(self._RESTAURANTS_LOADED, action_runner) | |
| 606 action_runner.WaitForElement(selector=self._RESTAURANTS_LINK) | |
| 607 action_runner.Wait(3) # User reads about restaurant | |
| 608 self._ClickLink(self._RESTAURANTS_LINK, action_runner) | |
| 609 action_runner.Wait(1) # Reading description | |
| 610 | |
| 611 # Open directions to the restaurant from Google. | |
| 612 self._ClickLink(self._DIRECTIONS_LINK, action_runner) | |
| 613 action_runner.Wait(0.5) | |
| 614 action_runner.EnterText('Google Mountain View') | |
| 615 action_runner.PressKey('Return') | |
| 616 action_runner.WaitForElement(selector=self._DIRECTIONS_LOADED) | |
| 617 action_runner.PinchElement(selector=self._MAP_LAYER) | |
| 618 action_runner.WaitForNetworkQuiescence() | |
| 619 action_runner.Wait(2) # Seeing direction | |
| 620 | |
| 621 def _ClickLink(self, selector, action_runner): | |
| 622 action_runner.WaitForElement(selector=selector) | |
| 623 action_runner.ClickElement(selector=selector) | |
| OLD | NEW |