sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #21339
Re: [Question #236452]: Continue script execution despite error
Question #236452 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/236452
Eugene S proposed the following answer:
You could just create a custom finder function. For example something
like that:
def tryDetect(object,retries,highLight=1):
"""Attempts to detect the "object" for "retries" times.
"""
localLog.info("Trying to detect %s image... %d attempts will be made", object, retries)
for n in range(retries):
if exists(object):
localLog.info("%s image detected!", object)
detectedObj = find(object)
if (highLight == 1):
localLog.debug("highLight argument is set to %d",highLight)
detectedObj.highlight(1)
else:
localLog.debug("highLight argument is set to %d",highLight)
failStatus = 0 # PASS => failStatus = 0
return detectedObj
else:
localLog.info("%s image was not detected in iteration %d", object, n+1)
waitFor(1)
if n == retries - 1: #If the number of iterations exhausted and the desired object was not yet detected
localLog.debug("Number of retries exceeded...")
failStatus = 1 # FAIL => failStatus = 1
takeScreenShot(testName)
localLog.error("%s test step FAILED!", testName)
exit(1)
--
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.