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

Unified Diff: tools/telemetry/telemetry/page/actions/wait.py

Issue 22883011: Removing Page.WaitToLoad and update all pagesets to use explicit wait actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Putting default navigate_steps inside page_set rather than page Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/page/actions/tap_element.py ('k') | tools/telemetry/telemetry/page/page.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/page/actions/wait.py
diff --git a/tools/telemetry/telemetry/page/actions/wait.py b/tools/telemetry/telemetry/page/actions/wait.py
index d610cd4bcb724b15119721cfe5cff0541c1a48f6..861c9163534e1c3d7b03052f48535bb490242343 100644
--- a/tools/telemetry/telemetry/page/actions/wait.py
+++ b/tools/telemetry/telemetry/page/actions/wait.py
@@ -14,17 +14,14 @@ class WaitAction(page_action.PageAction):
super(WaitAction, self).__init__(attributes)
def RunsPreviousAction(self):
- assert hasattr(self, 'condition')
- return self.condition == 'navigate' or self.condition == 'href_change'
+ return (getattr(self, 'condition', None) == 'navigate' or
+ getattr(self, 'condition', None) == 'href_change')
def RunAction(self, page, tab, previous_action):
- assert hasattr(self, 'condition')
-
- if self.condition == 'duration':
- assert hasattr(self, 'seconds')
+ if hasattr(self, 'seconds'):
time.sleep(self.seconds)
- elif self.condition == 'navigate':
+ elif getattr(self, 'condition', None) == 'navigate':
if not previous_action:
raise page_action.PageActionFailed('You need to perform an action '
'before waiting for navigate.')
@@ -32,7 +29,7 @@ class WaitAction(page_action.PageAction):
action_to_perform = lambda: previous_action.RunAction(page, tab, None)
tab.PerformActionAndWaitForNavigate(action_to_perform, self.timeout)
- elif self.condition == 'href_change':
+ elif getattr(self, 'condition', None) == 'href_change':
if not previous_action:
raise page_action.PageActionFailed('You need to perform an action '
'before waiting for a href change.')
@@ -42,7 +39,7 @@ class WaitAction(page_action.PageAction):
util.WaitFor(lambda: tab.EvaluateJavaScript(
'document.location.href') != old_url, self.timeout)
- elif self.condition == 'element':
+ elif getattr(self, 'condition', None) == 'element':
if hasattr(self, 'text'):
callback_code = 'function(element) { return element != null; }'
util.WaitFor(
@@ -64,7 +61,8 @@ class WaitAction(page_action.PageAction):
else:
raise page_action.PageActionFailed(
'No element condition given to wait')
- elif self.condition == 'javascript':
- assert hasattr(self, 'javascript')
+ elif hasattr(self, 'javascript'):
util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript),
self.timeout)
+ else:
+ raise page_action.PageActionFailed('No wait condition found')
« no previous file with comments | « tools/telemetry/telemetry/page/actions/tap_element.py ('k') | tools/telemetry/telemetry/page/page.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698