Bug 758195 - Add test for implicit waits. r=jgriffin
authorDavid Burns <dburns@mozilla.com>
Thu, 24 May 2012 10:48:30 -0700
changeset 154421 a1bfe3e4d8070c9353c02c72b5ed90a7f99f7700
parent 154420 ac6eacb47d55087348637251790abbf793e25a1b
child 154422 7631db8c900d1599d71bcd03fd10309c943282e3
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs758195
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 758195 - Add test for implicit waits. r=jgriffin
testing/marionette/client/marionette/tests/unit/test_implicit_waits.py
testing/marionette/client/marionette/tests/unit/unit-tests.ini
testing/marionette/client/marionette/www/test_dynamic.html
new file mode 100644
--- /dev/null
+++ b/testing/marionette/client/marionette/tests/unit/test_implicit_waits.py
@@ -0,0 +1,28 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from marionette_test import MarionetteTestCase
+from errors import NoSuchElementException
+
+class TestImplicitWaits(MarionetteTestCase):
+    def testShouldImplicitlyWaitForASingleElement(self):
+        test_html = self.marionette.absolute_url("test_dynamic.html")
+        self.marionette.navigate(test_html)
+        add = self.marionette.find_element("id", "adder")
+        self.marionette.set_search_timeout("3000")
+        add.click()
+        # All is well if this doesnt throw
+        self.marionette.find_element("id", "box0")
+
+    def testShouldStillFailToFindAnElementWhenImplicitWaitsAreEnabled(self):
+        test_html = self.marionette.absolute_url("test_dynamic.html")
+        self.marionette.navigate(test_html)
+        self.marionette.set_search_timeout("3000")
+        try:
+            self.marionette.find_element("id", "box0")
+            self.fail("Should have thrown a a NoSuchElementException")
+        except NoSuchElementException:
+            pass
+        except Exception:
+            self.fail("Should have thrown a NoSuchElementException")
--- a/testing/marionette/client/marionette/tests/unit/unit-tests.ini
+++ b/testing/marionette/client/marionette/tests/unit/unit-tests.ini
@@ -78,8 +78,10 @@ b2g = false
 [test_appcache.py]
 [test_screenshot.py]
 [test_cookies.py]
 b2g = false
 [test_window_title.py]
 b2g = false
 [test_window_type.py]
 b2g = false
+
+[test_implicit_waits.py]
new file mode 100644
--- /dev/null
+++ b/testing/marionette/client/marionette/www/test_dynamic.html
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+    "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+  <head>
+    <title></title>
+    <script type="text/javascript">
+      var next = 0;
+
+      function addMore() {
+        var box = document.createElement('DIV');
+        box.id = 'box' + next++;
+        box.className = 'redbox';
+        box.style.width = '150px';
+        box.style.height = '150px';
+        box.style.backgroundColor = 'red';
+        box.style.border = '1px solid black';
+        box.style.margin = '5px';
+        window.setTimeout(function() {
+          document.body.appendChild(box);
+          }, 1000);
+        }
+
+        function reveal() {
+          var elem = document.getElementById('revealed');
+          window.setTimeout(function() {
+            elem.style.display = '';
+          }, 1000);
+        }
+      </script>
+    </head>
+    <body>
+      <input id="adder" type="button" value="Add a box!" onclick="addMore()"/>
+
+      <input id="reveal" type="button" value="Reveal a new input" onclick="reveal();" />
+
+      <input id="revealed" style="display:none;" />
+    </body>
+  </html>