← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #232139]: observe quitting long before it should

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
interesting solution.

looks like being some workflow, where you want to use the onAppear
events to trigger the next action.

On the first glance I cannot see any scripting problems. It should do
what you intended.

The fact, that the observe stops can only have one reason: at that time it thinks, all onAppear-images have appeared.
This is the current implementation of the observe: it stops, when all registered events have occurred once. An event is no longer observed after happening once during an observe. It latest stops after the given time is consumed.

--- If it really is a sequential workflow (I guess so), I never would implement it this way. 
I would do it this way:

# startup stuff: get app window and trigger first step
imgNext = "1373388849234.png"

if exists(image_1stStep, 99): 
    with regionAppWindow:
        # do what is needed
        click(imgNext)
        
else:
    print "1st step did not appear"
    exit(1)

if exists(image_2ndStep, 99): 
    # you know what :-;

# and so on

This is clear and straightforward and easy to debug and to make robust.

If you want to repeat the workflow, just put the if blocks into a while
loop.

--- how to debug your solution
- put a 
print "in handler xyz" 
at the top of every handler, to see which are visited
- run in slow motion, to see the click events
- run the script from command line with debug level 3, to see more internal steps

One more thing:
the search for the appear events are restricted to the app window region, but the actions in the handlers are not.
You might do that using:
with e.region:

Since you use the function click_next(), the search for the next button
will not be restricted to the app window region.

easiest solution is to use a global image variable like
imgNext = "1373388849234.png"

and
click(imgNext) in the handlers

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