1 from selenium import selenium
4 from ConfigParser import ConfigParser
10 filename = "config.cfg"
17 server = c.get('config', 'server')
18 url= c.get('config', 'url')
19 if c.has_option('config', 'timeout'):
20 MAX_TEST_LENGTH = int(c.get('config', 'timeout'))
23 sections = c.sections()
27 targets[s] = dict(c.items(s))
28 targets[s]['name'] = s
30 if sys.argv[1] == "all":
31 browsers = list(targets.values())
32 elif sys.argv[1] not in targets:
33 print "Invalid target"
36 browsers = [targets[sys.argv[1]]]
45 print "Running %s on %s" % (b['name'], b['host'])
46 s = selenium(b['host'], 4444, "*%s" % b['browsercmd'], server)
49 s.open_window(url, "test_running")
51 s.select_window("test_running")
57 count = int(s.get_eval("window.document.getElementById('testtable').getElementsByTagName('tr').length"))
62 last_change = time.time()
64 new_ok = int(s.get_eval('window.Test.AnotherWay._g_ok_pages'))
65 new_fail = int(s.get_eval('window.Test.AnotherWay._g_fail_pages'))
66 if new_ok != ok or new_fail != fail:
69 last_change = time.time()
71 if (ok + fail) >= count:
73 if time.time() - last_change > MAX_TEST_LENGTH:
74 raise Exception("Failed: with %s okay and %s failed, ran out of time: %s is more than %s" % (ok, fail, (time.time() - last_change), MAX_TEST_LENGTH))
78 print "Failed: %s" % fail
79 html = s.get_eval("window.document.getElementById('results').innerHTML").encode("utf-8")
82 <meta content="text/html; charset=utf-8" http-equiv="content-type" />
84 <body>%s</body></html>""" % html
86 f = open("fail.%s.%s.html" % (time.time(), b['name']), "w")
89 except KeyboardInterrupt, E:
91 print "Stopped by keyboard interrupt"