OLD | NEW |
---|---|
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from page_sets.login_helpers import mobile_facebook_login | |
5 from page_sets.system_health import platforms | 6 from page_sets.system_health import platforms |
6 from page_sets.system_health import system_health_story | 7 from page_sets.system_health import system_health_story |
7 | 8 |
8 | 9 |
9 class _BrowsingStory(system_health_story.SystemHealthStory): | 10 class _BrowsingStory(system_health_story.SystemHealthStory): |
10 """Abstract base class for browsing stories. | 11 """Abstract base class for browsing stories. |
11 | 12 |
12 A browsing story visits items on the main page. Subclasses provide | 13 A browsing story visits items on the main page. Subclasses provide |
13 CSS selector to identify the items and implement interaction using | 14 CSS selector to identify the items and implement interaction using |
14 the helper methods of this class. | 15 the helper methods of this class. |
(...skipping 16 matching lines...) Expand all Loading... | |
31 def _ClickLink(self, action_runner, element_function): | 32 def _ClickLink(self, action_runner, element_function): |
32 action_runner.WaitForElement(element_function=element_function) | 33 action_runner.WaitForElement(element_function=element_function) |
33 action_runner.ClickElement(element_function=element_function) | 34 action_runner.ClickElement(element_function=element_function) |
34 self._WaitForNavigation(action_runner) | 35 self._WaitForNavigation(action_runner) |
35 | 36 |
36 def _NavigateBack(self, action_runner): | 37 def _NavigateBack(self, action_runner): |
37 action_runner.ExecuteJavaScript('window.history.back()') | 38 action_runner.ExecuteJavaScript('window.history.back()') |
38 self._WaitForNavigation(action_runner) | 39 self._WaitForNavigation(action_runner) |
39 | 40 |
40 | 41 |
41 class _NewsBrowsingStory(_BrowsingStory): | 42 class _NewsBrowsingStory(_BrowsingStory): |
petrcermak
2016/07/21 19:38:42
I suggest you move the _NewsBrowsingStory and _Med
Hannes Payer (out of office)
2016/07/26 16:02:09
Done.
| |
42 """Abstract base class for news user stories. | 43 """Abstract base class for news user stories. |
43 | 44 |
44 A news story imitates browsing a news website: | 45 A news story imitates browsing a news website: |
45 1. Load the main page. | 46 1. Load the main page. |
46 2. Open and scroll the first news item. | 47 2. Open and scroll the first news item. |
47 3. Go back to the main page and scroll it. | 48 3. Go back to the main page and scroll it. |
48 4. Open and scroll the second news item. | 49 4. Open and scroll the second news item. |
49 5. Go back to the main page and scroll it. | 50 5. Go back to the main page and scroll it. |
50 6. etc. | 51 6. etc. |
51 """ | 52 """ |
(...skipping 13 matching lines...) Expand all Loading... | |
65 def _ReadNewsItem(self, action_runner): | 66 def _ReadNewsItem(self, action_runner): |
66 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 67 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
67 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS) | 68 action_runner.Wait(self.ITEM_READ_TIME_IN_SECONDS) |
68 action_runner.RepeatableBrowserDrivenScroll( | 69 action_runner.RepeatableBrowserDrivenScroll( |
69 repeat_count=self.ITEM_SCROLL_REPEAT) | 70 repeat_count=self.ITEM_SCROLL_REPEAT) |
70 | 71 |
71 def _ScrollMainPage(self, action_runner): | 72 def _ScrollMainPage(self, action_runner): |
72 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 73 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
73 action_runner.RepeatableBrowserDrivenScroll( | 74 action_runner.RepeatableBrowserDrivenScroll( |
74 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) | 75 repeat_count=self.MAIN_PAGE_SCROLL_REPEAT) |
75 | 76 |
petrcermak
2016/07/21 19:38:42
nit: add extra blank line (I added justification i
Hannes Payer (out of office)
2016/07/26 16:02:09
Done.
| |
77 class _MediaBrowsingStory(_BrowsingStory): | |
78 """ Abstract base class for media user stories | |
79 | |
80 A media story imitates browsing a website with photo or video content: | |
81 1. Load a page showing a media item | |
82 2. Click on the next link to go to the next media item | |
83 3. etc. | |
84 """ | |
85 | |
86 ABSTRACT_STORY = True | |
87 ITEM_VIEW_TIME_IN_SECONDS = 1 | |
88 ITEMS_TO_VISIT = 30 | |
89 | |
90 def _DidLoadDocument(self, action_runner): | |
91 for i in xrange(self.ITEMS_TO_VISIT): | |
92 self._NavigateToItem(action_runner, self._ItemSelector(i)) | |
petrcermak
2016/07/21 19:38:42
Why do you define the _ItemSelector method when yo
Hannes Payer (out of office)
2016/07/26 16:02:09
Done. That is was leftover code experimenting with
| |
93 self._ViewMediaItem(action_runner) | |
94 | |
95 def _ViewMediaItem(self, action_runner): | |
96 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
97 action_runner.Wait(self.ITEM_VIEW_TIME_IN_SECONDS) | |
98 | |
76 | 99 |
77 ############################################################################## | 100 ############################################################################## |
78 # News browsing stories. | 101 # News browsing stories. |
79 ############################################################################## | 102 ############################################################################## |
80 | 103 |
81 | 104 |
82 class CnnStory(_NewsBrowsingStory): | 105 class CnnStory(_NewsBrowsingStory): |
83 """The second top website in http://www.alexa.com/topsites/category/News""" | 106 """The second top website in http://www.alexa.com/topsites/category/News""" |
84 NAME = 'browse:news:cnn' | 107 NAME = 'browse:news:cnn' |
85 URL = 'http://edition.cnn.com/' | 108 URL = 'http://edition.cnn.com/' |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 NAME = 'browse:news:washingtonpost' | 193 NAME = 'browse:news:washingtonpost' |
171 URL = 'https://www.washingtonpost.com/pwa' | 194 URL = 'https://www.washingtonpost.com/pwa' |
172 IS_SINGLE_PAGE_APP = True | 195 IS_SINGLE_PAGE_APP = True |
173 ITEM_SELECTOR = '.hed > a' | 196 ITEM_SELECTOR = '.hed > a' |
174 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | 197 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
175 | 198 |
176 def _DidLoadDocument(self, action_runner): | 199 def _DidLoadDocument(self, action_runner): |
177 # Close the popup window. | 200 # Close the popup window. |
178 action_runner.ClickElement(selector='.close') | 201 action_runner.ClickElement(selector='.close') |
179 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) | 202 super(WashingtonPostMobileStory, self)._DidLoadDocument(action_runner) |
203 | |
petrcermak
2016/07/21 19:38:42
nit: There should be two spaces between top-level
Hannes Payer (out of office)
2016/07/26 16:02:09
Done.
| |
204 ############################################################################## | |
205 # Media browsing stories. | |
206 ############################################################################## | |
207 | |
208 class FlickrMobileStory(_MediaBrowsingStory): | |
209 NAME = 'browse:media:flickr' | |
210 URL = ("https://www.flickr.com/photos/albertdros/27815579924/in/" | |
petrcermak
2016/07/21 19:38:42
s/"/'/g everywhere
Hannes Payer (out of office)
2016/07/26 16:02:09
Done.
| |
211 "explore-2016-07-20") | |
212 ITEM_SELECTOR = '.next-photo.photo-link' | |
213 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
214 IS_SINGLE_PAGE_APP = True | |
215 | |
216 def _ItemSelector(self, _): | |
217 return 0 | |
218 | |
219 class FlickrDesktopStory(_MediaBrowsingStory): | |
220 NAME = 'browse:media:flickr' | |
221 URL = ("https://www.flickr.com/photos/albertdros/27815579924/in/" | |
222 "explore-2016-07-20") | |
223 ITEM_SELECTOR = '.navigate-target.navigate-next' | |
224 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | |
225 IS_SINGLE_PAGE_APP = True | |
226 | |
227 def _ItemSelector(self, _): | |
228 return 0 | |
229 | |
230 class ImgurMobileStory(_MediaBrowsingStory): | |
231 NAME = 'browse:media:imgur' | |
232 URL = 'http://imgur.com/gallery/e6gPQ' | |
233 ITEM_SELECTOR = '.Navbar-customAction' | |
234 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
235 IS_SINGLE_PAGE_APP = True | |
236 def _ItemSelector(self, _): | |
237 return 0 | |
238 | |
239 class ImgurDesktopStory(_MediaBrowsingStory): | |
240 NAME = 'browse:media:imgur' | |
241 URL = 'http://imgur.com/gallery/e6gPQ' | |
242 ITEM_SELECTOR = '.navNext' | |
243 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | |
244 IS_SINGLE_PAGE_APP = True | |
245 def _ItemSelector(self, _): | |
246 return 0 | |
247 | |
248 class YoutubeMobileStory(_MediaBrowsingStory): | |
charliea (OOO until 10-5)
2016/07/29 20:10:01
I think it's worth noting that there are known iss
Hannes Payer (out of office)
2016/08/04 11:38:01
Acknowledged.
| |
249 NAME = 'browse:media:youtube' | |
250 URL = 'https://m.youtube.com/watch?v=njCDZWTI-xg' | |
251 ITEM_SELECTOR = '._mpfb > a' | |
252 IS_SINGLE_PAGE_APP = True | |
253 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
254 ITEM_VIEW_TIME_IN_SECONDS = 2 | |
charliea (OOO until 10-5)
2016/07/29 20:10:01
maybe petrcermak@chromium.org has an opinion here,
Hannes Payer (out of office)
2016/08/04 11:38:01
I will change it for all to two seconds.
| |
255 ITEMS_TO_VISIT = 15 | |
256 def _ItemSelector(self, _): | |
257 return 3 | |
258 | |
259 class YoutubeDesktopStory(_MediaBrowsingStory): | |
260 NAME = 'browse:media:youtube' | |
261 URL = 'https://www.youtube.com/watch?v=Ic07xTJoP34' | |
262 ITEM_SELECTOR = '.yt-uix-simple-thumb-related' | |
263 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | |
264 IS_SINGLE_PAGE_APP = True | |
265 ITEM_VIEW_TIME_IN_SECONDS = 2 | |
266 ITEMS_TO_VISIT = 15 | |
267 def _ItemSelector(self, _): | |
268 return 0 | |
269 | |
270 class FacebookMobileStory(_MediaBrowsingStory): | |
271 NAME = 'browse:media:facebookphotos' | |
272 URL = ("https://facebook.com/photo.php?fbid=10154398154450513&" | |
273 "id=255110695512&set=a.406278500512.172778.255110695512&" | |
274 "source=54&refid=13") | |
275 ITEM_SELECTOR = '._57-p > a' | |
276 IS_SINGLE_PAGE_APP = True | |
277 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY | |
278 ITEM_VIEW_TIME_IN_SECONDS = 2 | |
279 ITEMS_TO_VISIT = 20 | |
280 | |
281 def _ItemSelector(self, _): | |
282 return 1 | |
283 | |
284 class FacebookDesktopStory(_MediaBrowsingStory): | |
285 NAME = 'browse:media:facebookphotos' | |
286 URL = ("https://www.facebook.com/NASA/photos/a.67899501771.69169.54971236771/" | |
287 "10154267233981772/?type=3&theater") | |
288 ITEM_SELECTOR = '.snowliftPager.next' | |
289 IS_SINGLE_PAGE_APP = True | |
290 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY | |
291 ITEM_VIEW_TIME_IN_SECONDS = 2 | |
292 ITEMS_TO_VISIT = 20 | |
293 | |
294 def _ItemSelector(self, _): | |
295 return 0 | |
296 | |
297 def _Login(self, action_runner): | |
298 mobile_facebook_login.LoginAccount(action_runner, 'facebook3', | |
nednguyen
2016/07/21 17:32:00
Can you not use mobile_facebook_login here but:
1)
Hannes Payer (out of office)
2016/07/26 16:02:09
I experimented with that. The Desktop version gets
| |
299 self.credentials_path) | |
300 action_runner.Navigate("https://www.facebook.com") | |
301 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
OLD | NEW |