← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #188776]: Can't keep error handler from running

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
Ok, if this is your intention, then this approach will not work, since
with my suggested solution, the script will hang in the setup until the
observed situation happens, handle it and stop observing.

if you change it this way, it might do what you want:


def weatherAlertHandler(event):
    if exists(WeatherAlertNoBtn):
       click(getLastMatch())
    else:
       print("In weatherAlertHandler")
       assert exists(WeatherAlertNoBtn)

class SeaTowTests(unittest.TestCase):

    SeaTowArea = None

    def setUp(self):
        print("setting things up")
        SeaTowArea = find(SeaTowSim)
        SeaTowArea.highlight(3)
        SeaTowArea.onAppear(WeatherAlert, weatherAlertHandler)
        SeaTowArea.observe(FOREVER, background=True) # the observe runs in a separate process in background 
        # and script continues
        SeaTowTests.SeaTowArea = SeaTowArea # to save the region for tearDown in a class variable

    def tearDown(self):
        print("tearing things down")
        SeaTowTests.SeaTowArea.stopObserver()
        if exists(BackDayBtn):
            click(getLastMatch())
        elif exists(BackNightBtn):
            click(getLastMatch())

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.