-
Notifications
You must be signed in to change notification settings - Fork 0
/
pyuit.py
28 lines (25 loc) · 850 Bytes
/
pyuit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
from Controllers import RunUITests
import sys, json
import time
# Run tests using firefox or phantomjs
run_using_browser = "firefox"
retries = 0
max_retries_if_phantomjs_fails = 4
sleep_before_retrying = 3 # seconds
# Read rules as json from stdin and run UITests
data = sys.stdin.read()
while(True):
try:
# Get rules from stdin in json format on server
rules = json.loads(data)
test = RunUITests(rules)
test.run_ui_tests(run_using_browser)
break
except Exception, e:
# If phantomjs crashes it throws an exception containing string "ghostdriver" we retry
if str(e).lower().find("ghostdriver") >= 0 and (retries <= max_retries_if_phantomjs_fails):
time.sleep(sleep_before_retrying)
retries += 1
continue
raise e