Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index adc688a39ce2cde4ece9e3a5026ed489cff8f92e..570f283362e8ed43c17a1829f5fe3e374dd177f5 100755 |
--- a/chrome/test/pyautolib/pyauto.py |
+++ b/chrome/test/pyautolib/pyauto.py |
@@ -2915,7 +2915,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
occurs on a DOM node specified by |selector|. |
Args: |
- mutation_type: One of 'add', 'remove', or 'change'. |
+ mutation_type: One of 'add', 'remove', 'change', or 'exists'. |
selector: A DOMSelector object defining the DOM node to watch. The node |
must already exist if |mutation_type| is 'change'. |
expected_value: Optional regular expression to match against the node's |
@@ -2934,7 +2934,7 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
pyauto_errors.JSONInterfaceError if the automation call returns an error. |
RuntimeError if the injected javascript MutationObserver returns an error. |
""" |
- assert mutation_type in ('add', 'remove', 'change'), \ |
+ assert mutation_type in ('add', 'remove', 'change', 'exists'), \ |
'Unexpected value "%s" for mutation_type.' % mutation_type |
assert isinstance(selector, domselector.DOMSelector), \ |
'Unexpected type: selector is not a instance of DOMSelector.' |
@@ -2963,6 +2963,27 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase): |
raise RuntimeError(jsreturn) |
return observer_id |
+ def WaitForDomNode(self, selector, expected_value=None, timeout=-1, **kwargs): |
+ """Waits until a node matching selector exists in the DOM. |
Nirnimesh
2012/04/16 23:14:12
Add:
NOTE: This does NOT poll. It returns as soon
craigdh
2012/04/16 23:38:08
Done.
|
+ |
+ Args: |
+ selector: A DOMSelector object defining the DOM node to wait for. |
+ expected_value: Optional regular expression to match against the node's |
+ textContent attribute. Defaults to None. |
+ timeout: Time to wait for the node to exist before raising an exception, |
+ defaults to the default automation timeout. |
+ |
+ Any additional keyword arguments are passed on to ExecuteJavascript and |
+ can be used to select the tab where the DOM MutationObserver is created. |
+ |
+ Raises: |
+ pyauto_errors.JSONInterfaceError if the automation call returns an error. |
+ RuntimeError if the injected javascript MutationObserver returns an error. |
+ """ |
+ observer_id = self.AddDomMutationObserver('exists', selector, |
+ expected_value, **kwargs) |
+ self.GetNextEvent(observer_id, timeout=timeout) |
+ |
def GetNextEvent(self, observer_id=-1, blocking=True, timeout=-1): |
"""Waits for an observed event to occur. |