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') |