Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(246)

Side by Side Diff: tools/perf/page_sets/system_health/browsing_stories.py

Issue 2787103003: Add System health stories for Emerging market (Closed)
Patch Set: nits. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 146
135 class FlipboardDesktopStory(_NewsBrowsingStory): 147 class FlipboardDesktopStory(_ArticleBrowsingStory):
136 NAME = 'browse:news:flipboard' 148 NAME = 'browse:news:flipboard'
137 URL = 'https://flipboard.com/explore' 149 URL = 'https://flipboard.com/explore'
138 IS_SINGLE_PAGE_APP = True 150 IS_SINGLE_PAGE_APP = True
139 ITEM_SELECTOR = '.cover-image' 151 ITEM_SELECTOR = '.cover-image'
140 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 152 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
141 153
142 154
143 # crbug.com/657665 for win and mac 155 # crbug.com/657665 for win and mac
144 @decorators.Disabled('win', 'mac') 156 @decorators.Disabled('win', 'mac')
145 class HackerNewsStory(_NewsBrowsingStory): 157 class HackerNewsStory(_ArticleBrowsingStory):
146 NAME = 'browse:news:hackernews' 158 NAME = 'browse:news:hackernews'
147 URL = 'https://news.ycombinator.com' 159 URL = 'https://news.ycombinator.com'
148 ITEM_SELECTOR = '.athing .title > a' 160 ITEM_SELECTOR = '.athing .title > a'
149 161
150 162
151 class NytimesMobileStory(_NewsBrowsingStory): 163 class NytimesMobileStory(_ArticleBrowsingStory):
152 """The third top website in http://www.alexa.com/topsites/category/News""" 164 """The third top website in http://www.alexa.com/topsites/category/News"""
153 NAME = 'browse:news:nytimes' 165 NAME = 'browse:news:nytimes'
154 URL = 'http://mobile.nytimes.com' 166 URL = 'http://mobile.nytimes.com'
155 ITEM_SELECTOR = '.sfgAsset-link' 167 ITEM_SELECTOR = '.sfgAsset-link'
156 # Visiting more items causes OOM. 168 # Visiting more items causes OOM.
157 ITEMS_TO_VISIT = 2 169 ITEMS_TO_VISIT = 2
158 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 170 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
159 171
160 172
161 class NytimesDesktopStory(_NewsBrowsingStory): 173 class NytimesDesktopStory(_ArticleBrowsingStory):
162 """The third top website in http://www.alexa.com/topsites/category/News""" 174 """The third top website in http://www.alexa.com/topsites/category/News"""
163 NAME = 'browse:news:nytimes' 175 NAME = 'browse:news:nytimes'
164 URL = 'http://www.nytimes.com' 176 URL = 'http://www.nytimes.com'
165 ITEM_SELECTOR = '.story-heading > a' 177 ITEM_SELECTOR = '.story-heading > a'
166 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 178 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
167 179
168 180
169 # Desktop qq.com opens a news item in a separate tab, for which the back button 181 # Desktop qq.com opens a news item in a separate tab, for which the back button
170 # does not work. 182 # does not work.
171 class QqMobileStory(_NewsBrowsingStory): 183 class QqMobileStory(_ArticleBrowsingStory):
172 NAME = 'browse:news:qq' 184 NAME = 'browse:news:qq'
173 URL = 'http://news.qq.com' 185 URL = 'http://news.qq.com'
174 ITEM_SELECTOR = '.list .full a' 186 ITEM_SELECTOR = '.list .full a'
175 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 187 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
176 TAGS = [story_tags.INTERNATIONAL] 188 TAGS = [story_tags.INTERNATIONAL]
177 189
178 190
179 class RedditDesktopStory(_NewsBrowsingStory): 191 class RedditDesktopStory(_ArticleBrowsingStory):
180 """The top website in http://www.alexa.com/topsites/category/News""" 192 """The top website in http://www.alexa.com/topsites/category/News"""
181 NAME = 'browse:news:reddit' 193 NAME = 'browse:news:reddit'
182 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' 194 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week'
183 ITEM_SELECTOR = '.thing .title > a' 195 ITEM_SELECTOR = '.thing .title > a'
184 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 196 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
185 197
186 198
187 class RedditMobileStory(_NewsBrowsingStory): 199 class RedditMobileStory(_ArticleBrowsingStory):
188 """The top website in http://www.alexa.com/topsites/category/News""" 200 """The top website in http://www.alexa.com/topsites/category/News"""
189 NAME = 'browse:news:reddit' 201 NAME = 'browse:news:reddit'
190 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week' 202 URL = 'https://www.reddit.com/r/news/top/?sort=top&t=week'
191 IS_SINGLE_PAGE_APP = True 203 IS_SINGLE_PAGE_APP = True
192 ITEM_SELECTOR = '.PostHeader__post-title-line' 204 ITEM_SELECTOR = '.PostHeader__post-title-line'
193 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 205 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
194 206
195 207
196 class TwitterMobileStory(_NewsBrowsingStory): 208 class TwitterMobileStory(_ArticleBrowsingStory):
197 NAME = 'browse:social:twitter' 209 NAME = 'browse:social:twitter'
198 URL = 'https://www.twitter.com/nasa' 210 URL = 'https://www.twitter.com/nasa'
199 ITEM_SELECTOR = '.Tweet-text' 211 ITEM_SELECTOR = '.Tweet-text'
200 CONTAINER_SELECTOR = '.NavigationSheet' 212 CONTAINER_SELECTOR = '.NavigationSheet'
201 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 213 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
202 214
203 215
204 @decorators.Disabled('win') # crbug.com/662971 216 @decorators.Disabled('win') # crbug.com/662971
205 class TwitterDesktopStory(_NewsBrowsingStory): 217 class TwitterDesktopStory(_ArticleBrowsingStory):
206 NAME = 'browse:social:twitter' 218 NAME = 'browse:social:twitter'
207 URL = 'https://www.twitter.com/nasa' 219 URL = 'https://www.twitter.com/nasa'
208 IS_SINGLE_PAGE_APP = True 220 IS_SINGLE_PAGE_APP = True
209 ITEM_SELECTOR = '.tweet-text' 221 ITEM_SELECTOR = '.tweet-text'
210 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 222 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
211 223
212 224
213 class WashingtonPostMobileStory(_NewsBrowsingStory): 225 class WashingtonPostMobileStory(_ArticleBrowsingStory):
214 """Progressive website""" 226 """Progressive website"""
215 NAME = 'browse:news:washingtonpost' 227 NAME = 'browse:news:washingtonpost'
216 URL = 'https://www.washingtonpost.com/pwa' 228 URL = 'https://www.washingtonpost.com/pwa'
217 IS_SINGLE_PAGE_APP = True 229 IS_SINGLE_PAGE_APP = True
218 ITEM_SELECTOR = '.hed > a' 230 ITEM_SELECTOR = '.hed > a'
219 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 231 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
220 _CLOSE_BUTTON_SELECTOR = '.close' 232 _CLOSE_BUTTON_SELECTOR = '.close'
221 233
222 def _DidLoadDocument(self, action_runner): 234 def _DidLoadDocument(self, action_runner):
223 # Close the popup window. On Nexus 9 (and probably other tables) the popup 235 # 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 236 # 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 237 # 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. 238 # popup is transparent, so this is mostly an aesthetical issue.
227 has_button = action_runner.EvaluateJavaScript( 239 has_button = action_runner.EvaluateJavaScript(
228 '!!document.querySelector({{ selector }})', 240 '!!document.querySelector({{ selector }})',
229 selector=self._CLOSE_BUTTON_SELECTOR) 241 selector=self._CLOSE_BUTTON_SELECTOR)
230 if has_button: 242 if has_button:
231 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR) 243 action_runner.ClickElement(selector=self._CLOSE_BUTTON_SELECTOR)
232 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) 244 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner)
233 245
234 246
235 ############################################################################## 247 ##############################################################################
236 # Search browsing stories. 248 # Search browsing stories.
237 ############################################################################## 249 ##############################################################################
238 250
239 251
240 @decorators.Disabled('win') # crbug.com/673775 252 @decorators.Disabled('win') # crbug.com/673775
241 class GoogleDesktopStory(_NewsBrowsingStory): 253 class GoogleDesktopStory(_ArticleBrowsingStory):
242 """ 254 """
243 A typical google search story: 255 A typical google search story:
244 _ Start at https://www.google.com/search?q=flower 256 _ Start at https://www.google.com/search?q=flower
245 _ Click on the wikipedia link & navigate to 257 _ Click on the wikipedia link & navigate to
246 https://en.wikipedia.org/wiki/Flower 258 https://en.wikipedia.org/wiki/Flower
247 _ Scroll down the wikipedia page about flower. 259 _ Scroll down the wikipedia page about flower.
248 _ Back to the search main page. 260 _ Back to the search main page.
249 _ Refine the search query to 'flower delivery'. 261 _ Refine the search query to 'flower delivery'.
250 _ Scroll down the page. 262 _ Scroll down the page.
251 _ Click the next page result of 'flower delivery'. 263 _ Click the next page result of 'flower delivery'.
(...skipping 30 matching lines...) Expand all
282 294
283 # Scroll down & click next search result page. 295 # Scroll down & click next search result page.
284 action_runner.Wait(2) 296 action_runner.Wait(2)
285 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) 297 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR)
286 action_runner.Wait(2) 298 action_runner.Wait(2)
287 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) 299 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR)
288 action_runner.Wait(2) 300 action_runner.Wait(2)
289 action_runner.ScrollPage() 301 action_runner.ScrollPage()
290 302
291 303
292 class GoogleIndiaDesktopStory(_NewsBrowsingStory): 304 class GoogleIndiaDesktopStory(_ArticleBrowsingStory):
293 """ 305 """
294 A typical google search story in India: 306 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` 307 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. 308 2. Scroll down the page.
297 3. Refine the query & click search box, which navigates to 309 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 310 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. 311 4. Scroll down the page.
300 5. Click the next page result 312 5. Click the next page result
301 6. Scroll the search result page. 313 6. Scroll the search result page.
302 314
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 action_runner.tab.WaitForDocumentReadyStateToBeComplete() 381 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
370 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) 382 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS)
371 383
372 384
373 class ImgurMobileStory(_MediaBrowsingStory): 385 class ImgurMobileStory(_MediaBrowsingStory):
374 NAME = 'browse:media:imgur' 386 NAME = 'browse:media:imgur'
375 URL = 'http://imgur.com/gallery/5UlBN' 387 URL = 'http://imgur.com/gallery/5UlBN'
376 ITEM_SELECTOR = '.Navbar-customAction' 388 ITEM_SELECTOR = '.Navbar-customAction'
377 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 389 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
378 IS_SINGLE_PAGE_APP = True 390 IS_SINGLE_PAGE_APP = True
391 TAGS = [story_tags.EMERGING_MARKET]
379 392
380 393
381 # crbug.com/704197 for win and mac 394 # crbug.com/704197 for win and mac
382 @decorators.Disabled('win', 'mac') 395 @decorators.Disabled('win', 'mac')
383 class ImgurDesktopStory(_MediaBrowsingStory): 396 class ImgurDesktopStory(_MediaBrowsingStory):
384 NAME = 'browse:media:imgur' 397 NAME = 'browse:media:imgur'
385 URL = 'http://imgur.com/gallery/5UlBN' 398 URL = 'http://imgur.com/gallery/5UlBN'
386 ITEM_SELECTOR = '.navNext' 399 ITEM_SELECTOR = '.navNext'
387 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 400 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
388 IS_SINGLE_PAGE_APP = True 401 IS_SINGLE_PAGE_APP = True
389 402
390 403
391 class YouTubeMobileStory(_MediaBrowsingStory): 404 class YouTubeMobileStory(_MediaBrowsingStory):
392 NAME = 'browse:media:youtube' 405 NAME = 'browse:media:youtube'
393 URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' 406 URL = 'https://m.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false'
394 ITEM_SELECTOR = '._mhgb > a' 407 ITEM_SELECTOR = '._mhgb > a'
395 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 408 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
396 IS_SINGLE_PAGE_APP = True 409 IS_SINGLE_PAGE_APP = True
397 ITEM_SELECTOR_INDEX = 3 410 ITEM_SELECTOR_INDEX = 3
398 TAGS = [story_tags.JAVASCRIPT_HEAVY] 411 TAGS = [story_tags.JAVASCRIPT_HEAVY]
412 TAGS = [story_tags.EMERGING_MARKET]
399 413
400 414
401 class YouTubeDesktopStory(_MediaBrowsingStory): 415 class YouTubeDesktopStory(_MediaBrowsingStory):
402 NAME = 'browse:media:youtube' 416 NAME = 'browse:media:youtube'
403 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' 417 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false'
404 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' 418 ITEM_SELECTOR = '.yt-uix-simple-thumb-related'
405 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY 419 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY
406 IS_SINGLE_PAGE_APP = True 420 IS_SINGLE_PAGE_APP = True
407 # A longer view time allows videos to load and play. 421 # A longer view time allows videos to load and play.
408 ITEM_VIEW_TIME_IN_SECONDS = 5 422 ITEM_VIEW_TIME_IN_SECONDS = 5
409 ITEMS_TO_VISIT = 8 423 ITEMS_TO_VISIT = 8
410 ITEM_SELECTOR_INDEX = 3 424 ITEM_SELECTOR_INDEX = 3
411 PLATFORM_SPECIFIC = True 425 PLATFORM_SPECIFIC = True
412 TAGS = [story_tags.JAVASCRIPT_HEAVY] 426 TAGS = [story_tags.JAVASCRIPT_HEAVY]
413 427
414 428
415 class FacebookPhotosMobileStory(_MediaBrowsingStory): 429 class FacebookPhotosMobileStory(_MediaBrowsingStory):
416 NAME = 'browse:media:facebook_photos' 430 NAME = 'browse:media:facebook_photos'
417 URL = ( 431 URL = (
418 'https://m.facebook.com/rihanna/photos/a.207477806675.138795.10092511675/1 0153911739606676/?type=3&source=54&ref=page_internal') 432 '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' 433 ITEM_SELECTOR = '._57-r.touchable'
420 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY 434 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
421 IS_SINGLE_PAGE_APP = True 435 IS_SINGLE_PAGE_APP = True
422 ITEM_SELECTOR_INDEX = 0 436 ITEM_SELECTOR_INDEX = 0
437 TAGS = [story_tags.EMERGING_MARKET]
423 438
424 439
425 class FacebookPhotosDesktopStory(_MediaBrowsingStory): 440 class FacebookPhotosDesktopStory(_MediaBrowsingStory):
426 NAME = 'browse:media:facebook_photos' 441 NAME = 'browse:media:facebook_photos'
427 URL = ( 442 URL = (
428 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater') 443 'https://www.facebook.com/rihanna/photos/a.207477806675.138795.10092511675 /10153911739606676/?type=3&theater')
429 ITEM_SELECTOR = '.snowliftPager.next' 444 ITEM_SELECTOR = '.snowliftPager.next'
430 # Recording currently does not work. The page gets stuck in the 445 # Recording currently does not work. The page gets stuck in the
431 # theater viewer. 446 # theater viewer.
432 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS 447 SUPPORTED_PLATFORMS = platforms.NO_PLATFORMS
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 inner_save_function = 'document.querySelector(".nameAndIcons")' 491 inner_save_function = 'document.querySelector(".nameAndIcons")'
477 action_runner.WaitForElement(element_function=inner_save_function) 492 action_runner.WaitForElement(element_function=inner_save_function)
478 action_runner.ClickElement(element_function=inner_save_function) 493 action_runner.ClickElement(element_function=inner_save_function)
479 action_runner.Wait(1) # Wait to make navigation realistic. 494 action_runner.Wait(1) # Wait to make navigation realistic.
480 495
481 # Close selection. 496 # Close selection.
482 x_element_function = ('document.querySelector(' 497 x_element_function = ('document.querySelector('
483 '".Button.borderless.close.visible")') 498 '".Button.borderless.close.visible")')
484 action_runner.ClickElement(element_function=x_element_function) 499 action_runner.ClickElement(element_function=x_element_function)
485 action_runner.Wait(1) # Wait to make navigation realistic. 500 action_runner.Wait(1) # Wait to make navigation realistic.
501
502
503 ##############################################################################
504 # Emerging market browsing stories.
505 ##############################################################################
506
507
508 class BrowseFlipKartMobileStory(_ArticleBrowsingStory):
509 NAME = 'browse:shopping:flipkart'
510 URL = 'https://flipkart.com/search?q=Mobile%20phone'
511 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
512 TAGS = [story_tags.EMERGING_MARKET]
513
514 ITEM_SELECTOR = '._1Xs2AW'
515 BACK_SELECTOR = '._3NH1qf'
516 ITEMS_TO_VISIT = 4
517 IS_SINGLE_PAGE_APP = True
518
519 def _NavigateBack(self, action_runner):
520 action_runner.ClickElement(selector=self.BACK_SELECTOR)
521
522
523 class BrowseAmazonMobileStory(_ArticleBrowsingStory):
524 NAME = 'browse:shopping:amazon'
525 URL = 'https://www.amazon.co.in/s/?field-keywords=Mobile'
526 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
527 TAGS = [story_tags.EMERGING_MARKET]
528
529 ITEM_SELECTOR = '.aw-search-results'
530 ITEMS_TO_VISIT = 4
531
532
533 class BrowseLazadaMobileStory(_ArticleBrowsingStory):
534 NAME = 'browse:shopping:lazada'
535 URL = 'https://www.lazada.co.id/catalog/?q=Wrist+watch'
536 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
537 TAGS = [story_tags.EMERGING_MARKET]
538
539 ITEM_SELECTOR = '.merchandise__link'
540 ITEMS_TO_VISIT = 1
541
542
543 class BrowseAvitoMobileStory(_ArticleBrowsingStory):
544 NAME = 'browse:shopping:avito'
545 URL = 'https://www.avito.ru/rossiya'
546 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
547 TAGS = [story_tags.EMERGING_MARKET]
548
549 ITEM_SELECTOR = '.item-link'
550 ITEMS_TO_VISIT = 4
551
552
553 class BrowseTOIMobileStory(_ArticleBrowsingStory):
554 NAME = 'browse:news:toi'
555 URL = 'http://m.timesofindia.com'
556 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
557 TAGS = [story_tags.EMERGING_MARKET]
558
559 ITEMS_TO_VISIT = 4
560 ITEM_SELECTOR = '.dummy-img'
561
562
563 class BrowseGloboMobileStory(_ArticleBrowsingStory):
564 NAME = 'browse:news:globo'
565 URL = 'http://www.globo.com'
566 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
567 TAGS = [story_tags.EMERGING_MARKET]
568
569 ITEMS_TO_VISIT = 4
570 ITEM_SELECTOR = '.hui-premium__title'
571
572
573 class BrowseCricBuzzMobileStory(_ArticleBrowsingStory):
574 NAME = 'browse:news:cricbuzz'
575 URL = 'http://m.cricbuzz.com'
576 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
577 TAGS = [story_tags.EMERGING_MARKET]
578
579 ITEMS_TO_VISIT = 3
580 ITEM_SELECTOR = '.list-content'
581
582
583
584 ##############################################################################
585 # Maps browsing stories.
586 ##############################################################################
587
588
589 class GoogleMapsMobileStory(system_health_story.SystemHealthStory):
590 """Story that browses google maps mobile page
591
592 This story searches for nearby restaurants on google maps website and finds
593 directions to a chosen restaurant from search results.
594 """
595 NAME = 'browse:tools:maps'
596 URL = 'https://maps.google.com/'
597 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY
598 TAGS = [story_tags.EMERGING_MARKET]
599
600 _MAPS_SEARCH_BOX_SELECTOR = '.ml-searchbox-placeholder'
601 _RESTAURANTS_LOADED = '.ml-panes-categorical-list-results'
602 _SEARCH_NEW_AREA_SELECTOR = '.ml-reissue-search-button-inner'
603 _RESTAURANTS_LINK = '.ml-entity-list-item-info'
604 _DIRECTIONS_LINK = '[class="ml-button ml-inner-button-directions-fab"]'
605 _DIRECTIONS_LOADED = ('[class="ml-fab-inner '
606 'ml-button ml-button-navigation-fab"]')
607 _MAP_LAYER = '.ml-map'
608
609 def _DidLoadDocument(self, action_runner):
610 # Submit search query.
611 self._ClickLink(self._MAPS_SEARCH_BOX_SELECTOR, action_runner)
612 action_runner.EnterText('restaurants near me')
613 action_runner.PressKey('Return')
614 action_runner.WaitForElement(selector=self._RESTAURANTS_LOADED)
615 action_runner.WaitForNetworkQuiescence()
616 action_runner.Wait(4) # User looking at restaurants
617
618 # Open the restaurant list and select the first.
619 self._ClickLink(self._RESTAURANTS_LOADED, action_runner)
620 action_runner.WaitForElement(selector=self._RESTAURANTS_LINK)
621 action_runner.Wait(3) # User reads about restaurant
622 self._ClickLink(self._RESTAURANTS_LINK, action_runner)
623 action_runner.Wait(1) # Reading description
624
625 # Open directions to the restaurant from Google.
626 self._ClickLink(self._DIRECTIONS_LINK, action_runner)
627 action_runner.Wait(0.5)
628 action_runner.EnterText('Google Mountain View')
629 action_runner.PressKey('Return')
630 action_runner.WaitForElement(selector=self._DIRECTIONS_LOADED)
631 action_runner.PinchElement(selector=self._MAP_LAYER)
632 action_runner.WaitForNetworkQuiescence()
633 action_runner.Wait(2) # Seeing direction
634
635 def _ClickLink(self, selector, action_runner):
636 action_runner.WaitForElement(selector=selector)
637 action_runner.ClickElement(selector=selector)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698