How to disable Sikuli from Popping up error message on failure?

Asked by roi

Hi
I am new to Sikuli , When I execute the scripts from command line using the following command:
runIDE.cmd -r C:\SikuliX\Scipts\test.sikuli
Everything work ok and the scripts detects all elements.
when I want to test what happens when the script fails (for example closing the window which needs to be automated) , Sikuli obviously fails to find the element but it pops up window message error.
How can I change it to log the error without popping out the message?
Thanks

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
roi
Solved:
Last query:
Last reply:
Revision history for this message
Roman Podolyan (podolyan-roman) said :
#1

I thing you can build your custom function to decide what you want to do when script cann't find image.

Here is a piece of my code:
______
def try_click(our_image): # click-function with exception catched
        try:
                click(our_image)
        except FindFailed:
                pass
______

FindFailed is the exception generated when Sikuli doesn't find image. Instead of "pass" (placeholder instruction doing nothing) you can put there whatever you want, including logging to some file.

Revision history for this message
roi (azulay) said :
#2

thanks , that helps