| OLD | NEW |
| 1 # encoding: utf-8 |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # 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 |
| 3 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 4 | 5 |
| 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 from page_sets.login_helpers import pinterest_login | 9 from page_sets.login_helpers import pinterest_login |
| 9 | 10 |
| 10 from telemetry import decorators | 11 from telemetry import decorators |
| 12 from telemetry.util import js_template |
| 11 | 13 |
| 12 | 14 |
| 13 class _BrowsingStory(system_health_story.SystemHealthStory): | 15 class _BrowsingStory(system_health_story.SystemHealthStory): |
| 14 """Abstract base class for browsing stories. | 16 """Abstract base class for browsing stories. |
| 15 | 17 |
| 16 A browsing story visits items on the main page. Subclasses provide | 18 A browsing story visits items on the main page. Subclasses provide |
| 17 CSS selector to identify the items and implement interaction using | 19 CSS selector to identify the items and implement interaction using |
| 18 the helper methods of this class. | 20 the helper methods of this class. |
| 19 """ | 21 """ |
| 20 | 22 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 281 |
| 280 # Scroll down & click next search result page. | 282 # Scroll down & click next search result page. |
| 281 action_runner.Wait(2) | 283 action_runner.Wait(2) |
| 282 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 284 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 283 action_runner.Wait(2) | 285 action_runner.Wait(2) |
| 284 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) | 286 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 285 action_runner.Wait(2) | 287 action_runner.Wait(2) |
| 286 action_runner.ScrollPage() | 288 action_runner.ScrollPage() |
| 287 | 289 |
| 288 | 290 |
| 291 class GoogleIndiaDesktopStory(_NewsBrowsingStory): |
| 292 """ |
| 293 A typical google search story in India: |
| 294 1. Start at https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2` |
| 295 2. Scroll down the page. |
| 296 3. Refine the query & click search box, which navigates to |
| 297 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 |
| 298 4. Scroll down the page. |
| 299 5. Click the next page result |
| 300 6. Scroll the search result page. |
| 301 |
| 302 """ |
| 303 NAME = 'browse:search:google_india' |
| 304 URL = 'https://www.google.co.in/search?q=%E0%A4%AB%E0%A5%82%E0%A4%B2' |
| 305 _SEARCH_BOX_SELECTOR = 'input[aria-label="Search"]' |
| 306 _SEARCH_BUTTON_SELECTOR = 'button[aria-label="Google Search"]' |
| 307 _SEARCH_PAGE_2_SELECTOR = 'a[aria-label=\'Page 2\']' |
| 308 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
| 309 |
| 310 def _DidLoadDocument(self, action_runner): |
| 311 action_runner.Wait(2) |
| 312 action_runner.ScrollPage() |
| 313 action_runner.Wait(2) |
| 314 |
| 315 action_runner.ScrollPage(direction='up') |
| 316 |
| 317 # Refine search query in the search box. |
| 318 # TODO(nednguyen): replace this with input text gesture to make it more |
| 319 # realistic. |
| 320 action_runner.ExecuteJavaScript( |
| 321 js_template.Render( |
| 322 'document.querySelector({{ selector }}).value += "वितरण";', |
| 323 selector=self._SEARCH_BOX_SELECTOR)) |
| 324 action_runner.Wait(2) |
| 325 action_runner.ClickElement(selector=self._SEARCH_BUTTON_SELECTOR) |
| 326 |
| 327 # Scroll down & click next search result page. |
| 328 action_runner.Wait(2) |
| 329 action_runner.ScrollPageToElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 330 action_runner.Wait(2) |
| 331 action_runner.ClickElement(selector=self._SEARCH_PAGE_2_SELECTOR) |
| 332 action_runner.Wait(2) |
| 333 action_runner.ScrollPage() |
| 334 |
| 335 |
| 289 ############################################################################## | 336 ############################################################################## |
| 290 # Media browsing stories. | 337 # Media browsing stories. |
| 291 ############################################################################## | 338 ############################################################################## |
| 292 | 339 |
| 293 | 340 |
| 294 class _MediaBrowsingStory(_BrowsingStory): | 341 class _MediaBrowsingStory(_BrowsingStory): |
| 295 """Abstract base class for media user stories | 342 """Abstract base class for media user stories |
| 296 | 343 |
| 297 A media story imitates browsing a website with photo or video content: | 344 A media story imitates browsing a website with photo or video content: |
| 298 1. Load a page showing a media item | 345 1. Load a page showing a media item |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 inner_save_function = 'document.querySelector(".nameAndIcons")' | 471 inner_save_function = 'document.querySelector(".nameAndIcons")' |
| 425 action_runner.WaitForElement(element_function=inner_save_function) | 472 action_runner.WaitForElement(element_function=inner_save_function) |
| 426 action_runner.ClickElement(element_function=inner_save_function) | 473 action_runner.ClickElement(element_function=inner_save_function) |
| 427 action_runner.Wait(1) # Wait to make navigation realistic. | 474 action_runner.Wait(1) # Wait to make navigation realistic. |
| 428 | 475 |
| 429 # Close selection. | 476 # Close selection. |
| 430 x_element_function = ('document.querySelector(' | 477 x_element_function = ('document.querySelector(' |
| 431 '".Button.borderless.close.visible")') | 478 '".Button.borderless.close.visible")') |
| 432 action_runner.ClickElement(element_function=x_element_function) | 479 action_runner.ClickElement(element_function=x_element_function) |
| 433 action_runner.Wait(1) # Wait to make navigation realistic. | 480 action_runner.Wait(1) # Wait to make navigation realistic. |
| OLD | NEW |