]> git.pond.sub.org Git - eow/blobdiff - test/runtests.py
Simple selenium testrunner + a test case
[eow] / test / runtests.py
diff --git a/test/runtests.py b/test/runtests.py
new file mode 100644 (file)
index 0000000..56fb2be
--- /dev/null
@@ -0,0 +1,42 @@
+from selenium import selenium
+import unittest, time, re
+
+class runtests(unittest.TestCase):
+    def setUp(self):
+        self.verificationErrors = []
+        self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost:4242/")
+        self.selenium.start()
+    
+    def test_runtests(self):
+        sel = self.selenium
+        sel.open("/eow/static/login.html")
+        sel.type("username", "1")
+        sel.type("password", "1")
+        sel.click("//input[@value=' Login ']")
+        sel.wait_for_page_to_load("30000")
+        sel.answer_on_next_prompt("")
+        try: self.failUnless(re.search(r"\[[0-9]+,[0-9]+\]:", sel.get_text("prompt")))
+        except AssertionError, e: self.verificationErrors.append(str(e))
+        sel.type("inputfield", "cen #")
+        sel.key_up("inputfield", "\\13")
+        for i in range(60):
+            try:
+                if sel.is_text_present("sectors"): break
+            except: pass
+            time.sleep(1)
+        else: self.fail("time out")
+        sel.type("inputfield", "map #")
+        sel.key_up("inputfield", "\\13")
+        for i in range(60):
+            try:
+                if sel.is_text_present("012345"): break
+            except: pass
+            time.sleep(1)
+        else: self.fail("time out")
+    
+    def tearDown(self):
+        self.selenium.stop()
+        self.assertEqual([], self.verificationErrors)
+
+if __name__ == "__main__":
+    unittest.main()