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

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

Powered by Google App Engine
This is Rietveld 408576698