observe quitting long before it should

Asked by Tames McTigue

I'm trying to create a script that tests an installer. For some reason it quits about half way through even though I can't see any reason for it to. It runs up until after it sees and runs the "install_path_page" handler. Once it runs that handler, it quits with "[info] Exit code: 0"

This is running on Windows Server 2012 Standard using 64-bit Java 1.7.0_25 and 64-bit Sikuli IDE 1.0.0 with the "SupplementalObserveOnlyOnce" update.

Here is what I have so far. I plan on having observe run forever eventually and have the last handler stop the observation:

installer_path = 'C:\\Users\\Administrator\\Desktop\\my_windows_setup.exe'
license_company = 'company'
license_name = 'name'
license_count = 1
license_key = 'xxxxxxxxxxxxxxxxxxxxxxxx'
postgres_password = 'xxxxxxx'

def click_next():
    click("1373388849234.png")

def intro_page(event):
    click_next()

def eula_page(event):
    click(Pattern("1373388972249.png").targetOffset(-65,1))
    click_next()

def license_page(event):
    type(license_company + Key.TAB)
    type(license_name + Key.TAB)
    type(str(license_count) + Key.TAB)
    type(license_key)
    click_next()

def install_path_page(event):
    click_next()

def features_page(event):
    click_next()

def postgresql_path_page(event):
    click_next()

def postgresql_password_page(event):
    type(postgres_password + Key.TAB)
    type(postgres_password)
    click_next()

def web_ports_page(event):
    click_next()

def ready_to_install_page(event):
    click_next()

def begin_watching():
    es_installer = App(installer_path)
    es_installer.open()
    wait("1373389889359.png", FOREVER)

    reg = Region(App('Setup').window(0))
    reg.onAppear("1373389041327.png", intro_page)
    reg.onAppear("1373389063530.png", eula_page)
    reg.onAppear("1373389092077.png", license_page)
    reg.onAppear("1373390507593.png", install_path_page)
    reg.onAppear("1373392574702.png", features_page)
    reg.onAppear("1373390778484.png", postgresql_path_page)
    reg.onAppear("1373391295577.png", postgresql_password_page)
    reg.onAppear("1373391322733.png", web_ports_page)
    reg.onAppear("1373391349515.png", ready_to_install_page)
    reg.observe(600)

begin_watching()

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
RaiMan Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

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

Revision history for this message
RaiMan (raimund-hocke) said :
#2

One more thing:
If you get your workflow running with this observe approach, observe(FOREVER) would not repeat the workflow. It would stop if all events have appeared once.

while True:
    reg.observe(FOREVER)

would do this

Revision history for this message
Tames McTigue (tamesmctigue) said :
#3

Hi RaiMan,

Thank you for the tips, you may be right that there is a better way of doing this. The reason I am doing it this way is the fact that the dialog pages can be completely different depending on which OS and which features are chosen. I thought this would be a quick way of accounting for all of the patterns. Your way would probably be better overall since I'd know if something doesn't show up that I'm expecting to.

I do however think this is a bug. I wasn't aware that it would stop once it sees every onAppear image. To make sure this isn't happening, I used an image that there is no way would show up for one of the onAppear images. It still quits even though it should not. I ran it from the command line with d:3 and it doesn't give me any more information than the GUI does. Just shows it running the first few handlers like it should, then "[info] Exit code: 0".

Can you help with this problem?

Provide an answer of your own, or ask Tames McTigue for more information if necessary.

To post a message you must log in.