Index: tools/telemetry/telemetry/wait_action.py |
diff --git a/tools/telemetry/telemetry/wait_action.py b/tools/telemetry/telemetry/wait_action.py |
deleted file mode 100644 |
index b078f7e91f3abc5c7b3381c6e4f4ac619c8b9b1d..0000000000000000000000000000000000000000 |
--- a/tools/telemetry/telemetry/wait_action.py |
+++ /dev/null |
@@ -1,59 +0,0 @@ |
-# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
-# Use of this source code is governed by a BSD-style license that can be |
-# found in the LICENSE file. |
-import time |
- |
-from telemetry import page_action |
-from telemetry import util |
- |
-class WaitAction(page_action.PageAction): |
- DEFAULT_TIMEOUT = 60 |
- |
- def __init__(self, attributes=None): |
- super(WaitAction, self).__init__(attributes) |
- |
- def RunsPreviousAction(self): |
- assert hasattr(self, 'condition') |
- return self.condition == 'navigate' or self.condition == 'href_change' |
- |
- def RunAction(self, page, tab, previous_action): |
- assert hasattr(self, 'condition') |
- |
- if self.condition == 'duration': |
- assert hasattr(self, 'seconds') |
- time.sleep(self.seconds) |
- |
- elif self.condition == 'navigate': |
- if not previous_action: |
- raise page_action.PageActionFailed('You need to perform an action ' |
- 'before waiting for navigate.') |
- previous_action.WillRunAction() |
- action_to_perform = lambda: previous_action.RunAction(page, tab, None) |
- tab.PerformActionAndWaitForNavigate(action_to_perform) |
- |
- elif self.condition == 'href_change': |
- if not previous_action: |
- raise page_action.PageActionFailed('You need to perform an action ' |
- 'before waiting for a href change.') |
- previous_action.WillRunAction() |
- old_url = tab.EvaluateJavaScript('document.location.href') |
- previous_action.RunAction(page, tab, None) |
- util.WaitFor(lambda: tab.EvaluateJavaScript( |
- 'document.location.href') != old_url, self.DEFAULT_TIMEOUT) |
- |
- elif self.condition == 'element': |
- assert hasattr(self, 'text') or hasattr(self, 'selector') |
- if self.text: |
- callback_code = 'function(element) { return element != null; }' |
- util.WaitFor( |
- lambda: util.FindElementAndPerformAction( |
- tab, self.text, callback_code), self.DEFAULT_TIMEOUT) |
- elif self.selector: |
- util.WaitFor(lambda: tab.EvaluateJavaScript( |
- 'document.querySelector("%s") != null' % self.selector), |
- self.DEFAULT_TIMEOUT) |
- |
- elif self.condition == 'javascript': |
- assert hasattr(self, 'javascript') |
- util.WaitFor(lambda: tab.EvaluateJavaScript(self.javascript), |
- self.DEFAULT_TIMEOUT) |