Selenium : Do not stop if urlError.

parent a4126731
...@@ -47,6 +47,7 @@ def run(args): ...@@ -47,6 +47,7 @@ def run(args):
# Clean old test results if any # Clean old test results if any
openUrl('%s/TestTool_cleanUpTestResults?__ac_name=%s&__ac_password=%s' % ( openUrl('%s/TestTool_cleanUpTestResults?__ac_name=%s&__ac_password=%s' % (
config['base_url'], config['user'], config['password'])) config['base_url'], config['user'], config['password']))
try:
if getStatus(config['base_url']) is not '': if getStatus(config['base_url']) is not '':
print("ERROR : Impossible to clean old test result(s)") print("ERROR : Impossible to clean old test result(s)")
else: else:
...@@ -79,6 +80,8 @@ def run(args): ...@@ -79,6 +80,8 @@ def run(args):
config['base_url'], config['user'], config['password'])) config['base_url'], config['user'], config['password']))
print("Test finished and report sent, sleeping.") print("Test finished and report sent, sleeping.")
except urllib2.URLError, urlError:
print "Error: %s" % urlError.msg
sleep(3600) sleep(3600)
def openUrl(url): def openUrl(url):
...@@ -97,8 +100,15 @@ def openUrl(url): ...@@ -97,8 +100,15 @@ def openUrl(url):
return file_content return file_content
def getStatus(url): def getStatus(url):
try:
# Try 5 times.
for i in range(5):
try: try:
status = openUrl('%s/portal_tests/TestTool_getResults' % (url)) status = openUrl('%s/portal_tests/TestTool_getResults' % (url))
break
except urllib2.URLError, urlError:
if i is 4: raise
print("Warning : %s while getting status" % urlError.msg)
except urllib2.HTTPError, e: except urllib2.HTTPError, e:
if e.msg == "No Content": if e.msg == "No Content":
status = "" status = ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment