| 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.system_health import platforms | 5 from page_sets.system_health import platforms |
| 6 from page_sets.system_health import system_health_story | 6 from page_sets.system_health import system_health_story |
| 7 | 7 |
| 8 from page_sets.login_helpers import google_login | 8 from page_sets.login_helpers import google_login |
| 9 from page_sets.login_helpers import pandora_login | 9 from page_sets.login_helpers import pandora_login |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 if self.PLAY_SELECTOR: | 28 if self.PLAY_SELECTOR: |
| 29 self._WaitForAndClickElementBySelector(action_runner, self.PLAY_SELECTOR) | 29 self._WaitForAndClickElementBySelector(action_runner, self.PLAY_SELECTOR) |
| 30 self._WaitForPlayTime(action_runner) | 30 self._WaitForPlayTime(action_runner) |
| 31 # Stop media. | 31 # Stop media. |
| 32 self._WaitForAndClickElementBySelector(action_runner, self.STOP_SELECTOR) | 32 self._WaitForAndClickElementBySelector(action_runner, self.STOP_SELECTOR) |
| 33 | 33 |
| 34 def _NavigateToMedia(self, action_runner): | 34 def _NavigateToMedia(self, action_runner): |
| 35 raise NotImplementedError | 35 raise NotImplementedError |
| 36 | 36 |
| 37 def _WaitForAndClickElementBySelector(self, action_runner, selector): | 37 def _WaitForAndClickElementBySelector(self, action_runner, selector): |
| 38 element_function = 'document.querySelector("%s")' % selector | 38 action_runner.WaitForElement(selector=selector) |
| 39 action_runner.WaitForElement(element_function=element_function) | 39 action_runner.ClickElement(selector=selector) |
| 40 action_runner.ClickElement(element_function=element_function) | |
| 41 | 40 |
| 42 def _WaitForPlayTime(self, action_runner): | 41 def _WaitForPlayTime(self, action_runner): |
| 43 action_runner.Wait(self.PLAY_DURATION) | 42 action_runner.Wait(self.PLAY_DURATION) |
| 44 while self._GetTimeInSeconds(action_runner) < self.PLAY_DURATION: | 43 while self._GetTimeInSeconds(action_runner) < self.PLAY_DURATION: |
| 45 action_runner.Wait( | 44 action_runner.Wait( |
| 46 self.PLAY_DURATION - self._GetTimeInSeconds(action_runner)) | 45 self.PLAY_DURATION - self._GetTimeInSeconds(action_runner)) |
| 47 | 46 |
| 48 def _GetTimeInSeconds(self, action_runner): | 47 def _GetTimeInSeconds(self, action_runner): |
| 49 # TODO(catapult:#3028): Fix interpolation of JavaScript values. | 48 minutes, seconds = action_runner.EvaluateJavaScript( |
| 50 time_func = ( | 49 'document.querySelector({{ selector }}).textContent', |
| 51 'document.querySelector("%s").textContent' % self.TIME_SELECTOR) | 50 selector=self.TIME_SELECTOR).split(':') |
| 52 minutes, seconds = action_runner.EvaluateJavaScript(time_func).split(':') | |
| 53 return int(minutes * 60 + seconds) | 51 return int(minutes * 60 + seconds) |
| 54 | 52 |
| 55 | 53 |
| 56 ################################################################################ | 54 ################################################################################ |
| 57 # Audio stories. | 55 # Audio stories. |
| 58 ################################################################################ | 56 ################################################################################ |
| 59 | 57 |
| 60 | 58 |
| 61 @benchmark.Disabled('all') # crbug.com/649392 | 59 @benchmark.Disabled('all') # crbug.com/649392 |
| 62 class GooglePlayMusicDesktopStory(_MediaStory): | 60 class GooglePlayMusicDesktopStory(_MediaStory): |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 PLAY_SELECTOR = None | 107 PLAY_SELECTOR = None |
| 110 STOP_SELECTOR = '.pauseButton' | 108 STOP_SELECTOR = '.pauseButton' |
| 111 TIME_SELECTOR = '.elapsedTime' | 109 TIME_SELECTOR = '.elapsedTime' |
| 112 SEARCH_SELECTOR = '.searchInput' | 110 SEARCH_SELECTOR = '.searchInput' |
| 113 | 111 |
| 114 def _Login(self, action_runner): | 112 def _Login(self, action_runner): |
| 115 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) | 113 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) |
| 116 | 114 |
| 117 def _NavigateToMedia(self, action_runner): | 115 def _NavigateToMedia(self, action_runner): |
| 118 pass # Audio autoplays on Pandora, no need to search. | 116 pass # Audio autoplays on Pandora, no need to search. |
| OLD | NEW |