Update testcase
[eow] / test / runtests.py
1 from selenium import selenium
2 import unittest, time, re
3
4 class runtests(unittest.TestCase):
5     def setUp(self):
6         self.verificationErrors = []
7         self.selenium = selenium("localhost", 4444, "*chrome", "http://localhost:4242/")
8         self.selenium.start()
9     
10     def test_runtests(self):
11         sel = self.selenium
12         sel.open("/eow/static/login.html")
13         sel.type("username", "1")
14         sel.type("password", "1")
15         sel.click("//input[@value=' Login ']")
16         sel.wait_for_page_to_load("30000")
17         sel.answer_on_next_prompt("")
18         try: self.failUnless(re.search(r"\[[0-9]+,[0-9]+\]:", sel.get_text("prompt")))
19         except AssertionError, e: self.verificationErrors.append(str(e))
20         sel.type("inputfield", "cen #")
21         sel.key_up("inputfield", "\\13")
22         for i in range(60):
23             try:
24                 if sel.is_text_present("sectors"): break
25             except: pass
26             time.sleep(1)
27         else: self.fail("time out")
28         sel.type("inputfield", "map #")
29         sel.key_up("inputfield", "\\13")
30         for i in range(60):
31             try:
32                 if sel.is_text_present("012345"): break
33             except: pass
34             time.sleep(1)
35         else: self.fail("time out")
36     
37     def tearDown(self):
38         self.selenium.stop()
39         self.assertEqual([], self.verificationErrors)
40
41 if __name__ == "__main__":
42     unittest.main()