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

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

Issue 2618333006: [tools/perf] Fix JavaScript interpolation in action_runner calls (Closed)
Patch Set: Created 3 years, 11 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 # 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 28 matching lines...) Expand all
39 action_runner.WaitForElement(element_function=element_function) 39 action_runner.WaitForElement(element_function=element_function)
40 action_runner.ClickElement(element_function=element_function) 40 action_runner.ClickElement(element_function=element_function)
41 41
42 def _WaitForPlayTime(self, action_runner): 42 def _WaitForPlayTime(self, action_runner):
43 action_runner.Wait(self.PLAY_DURATION) 43 action_runner.Wait(self.PLAY_DURATION)
44 while self._GetTimeInSeconds(action_runner) < self.PLAY_DURATION: 44 while self._GetTimeInSeconds(action_runner) < self.PLAY_DURATION:
45 action_runner.Wait( 45 action_runner.Wait(
46 self.PLAY_DURATION - self._GetTimeInSeconds(action_runner)) 46 self.PLAY_DURATION - self._GetTimeInSeconds(action_runner))
47 47
48 def _GetTimeInSeconds(self, action_runner): 48 def _GetTimeInSeconds(self, action_runner):
49 # TODO(catapult:#3028): Fix interpolation of JavaScript values. 49 minutes, seconds = action_runner.EvaluateJavaScript(
50 time_func = ( 50 'document.querySelector({{ selector }}).textContent',
51 'document.querySelector("%s").textContent' % self.TIME_SELECTOR) 51 selector=self.TIME_SELECTOR).split(':')
52 minutes, seconds = action_runner.EvaluateJavaScript(time_func).split(':')
53 return int(minutes * 60 + seconds) 52 return int(minutes * 60 + seconds)
54 53
55 54
56 ################################################################################ 55 ################################################################################
57 # Audio stories. 56 # Audio stories.
58 ################################################################################ 57 ################################################################################
59 58
60 59
61 @benchmark.Disabled('all') # crbug.com/649392 60 @benchmark.Disabled('all') # crbug.com/649392
62 class GooglePlayMusicDesktopStory(_MediaStory): 61 class GooglePlayMusicDesktopStory(_MediaStory):
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 PLAY_SELECTOR = None 108 PLAY_SELECTOR = None
110 STOP_SELECTOR = '.pauseButton' 109 STOP_SELECTOR = '.pauseButton'
111 TIME_SELECTOR = '.elapsedTime' 110 TIME_SELECTOR = '.elapsedTime'
112 SEARCH_SELECTOR = '.searchInput' 111 SEARCH_SELECTOR = '.searchInput'
113 112
114 def _Login(self, action_runner): 113 def _Login(self, action_runner):
115 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path) 114 pandora_login.LoginAccount(action_runner, 'pandora', self.credentials_path)
116 115
117 def _NavigateToMedia(self, action_runner): 116 def _NavigateToMedia(self, action_runner):
118 pass # Audio autoplays on Pandora, no need to search. 117 pass # Audio autoplays on Pandora, no need to search.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698