How to do an easy not-found handling?
Anyone any idea how to get this into real world?
the background:
if you have a workflow like:
switchApp("app")
wait()
find()
click()
click()
type()
wait()
find()
click()
.... and so on
running in the IDE, you have some chance to see, when the script fails, what the cause may have been. When running as executable, you simply have to accept, that it stops working at all or goes into weird situations sometimes (there are questions and bug reports in this direction).
To make such a workflow more secure, you can intermix some python and logging, that checks at critical points, that we are still where we expect to be.
goOn = True
if find():
click(
else:
goOn = false
if goOn:
... further actions
You can use wait(), to only go on working if specific patterns are there, but wait has to be supplemented with some if/while constructs to trap the timeouts.
If you do this extensively, than you will come up with a script, that has 4 to 8 additional python statements for every Sikuli action. In german we say: you don't see the wood (my workflow), because of so many trees (+ python).
I would like to do something like that:
1. scenario (could be the default)
setTryEnvironment = "easy"
switchApp("app")
wait()
find()
click()
click()
type()
when I run the script: if the first not-found situation happens, the script stops and I get a message like this:
- not-found: the statement with line number
- a thumbnail with link to the picture that failed
- link to the screenshot with the last successful action
2. scenario
setTryEnvironment = "mature"
try:
wait()
find()
click()
error:
# not-found in the try block brings me here
(x, y, z, a, b, c) = error.get() # get some predefined information about the not-found
# do some evaluation and corrections and say
continue # goes back to the point of error and continues or
break # continues after the try block or
exit # stops the script with a configurable message
# after the try
click()
type()
statements outside a try are handled as scenario 1.
3. scenario
setTryEnvironment = "off"
should be like scenario 2 but without the easy option.
In longer scripts, you can have more than one setTryEnvironment that start working from this point on.
Anyone any idea how to get this into real world?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- RaiMan
- Solved:
- Last query:
- Last reply: