← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #680899]: how to recover from crashing of target application?

 

Question #680899 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/680899

RaiMan proposed the following answer:
looking into the implementation, I have to admit, that is is a mess and
does not seem to have been tested in all aspects.

But at least I have fond a solution, that should help you.

This is my example, that worked and sets a global FindFailed handler,
that is inherited by all following new Region objects.

again = True

def ffHandler(event):
    global again
    print "From handler: %s" % event
    if again:    
        event.setResponse(RETRY)
        again = False
    else:
        event.setResponse(ABORT)
    
FindFailed("testHandler").setFindFailedHandler(ffHandler)
use() # add the handler to the global SCREEN object
img = "img.png"
find(img)
hover()

The hack is "FindFailed("testHandler")", since setFindFailedHandler() is
not implemented as static method.

the constants to be used with event.setResponse in the handler are:
ABORT | SKIP | PROMPT | RETRY (see docs)

Instead of 
FindFailed("testHandler").setFindFailedHandler(ffHandler)
use() # add the handler to the global SCREEN object

you could also use
SCREEN.setFindFailedHandler(ffHandler)

If you decide to always use SCREEN as the search region (or a subregion created by setROI())
Hence this will only set a handler for the global SCREEN.

The implementation has to be revised and tested completely. The docs have to be revised too.
Thanks for finding and insisting on a solution ;-)

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.