← Back to team overview

sikuli-driver team mailing list archive

[Question #554900]: inconsistent error handling if findAll() loop

 

New question #554900 on Sikuli:
https://answers.launchpad.net/sikuli/+question/554900

In this code I am trying to use the if findAll() statement to respond when a search request generates a "This report cannot be completed" popup message. 

The if findAll(): locates an image (bold type "Information" header) and seeks to click an "Ok" button then resets search parameters to start a new search.
The else:  condition continues with a normal download and saves the request files in .xlsx and .pdf format.

Almost identical code versions are generating different and incorrect outcomes. Version 1 code was created in Sikuli 1.1.1, and it correctly handles the "This report cannot be completed" error condition BUT fails to handle a normal save condition. 

Version 2 (created in Sikuli 1.1.0) correctly handles the else: normal download (else:), but fails on the if findAll() condition when this appears ("This report cannot be completed" popup). I have tried creating images in all the different tools, saving images in various locations and pasting in code as plain text to eliminate the impact of any version differences. No error statements are showing in either version 1 or 2, e.g. image file not found? 

I am a rookie Python coder, so will not be shocked if found to be missing something obvious.

VERSION 1

click(Location(-801, 92))
wait(2)
type("44.07")
wait(1)
click(Location(-525, 361))
type(Key.ENTER)
wait(10)
r = Region(-937,209,142,50)
if findAll("Report-cannot-be-completed-v2.png"): 
    click(Location(-384, 347))
    wait(2)
    click(Location(-327, -14))
    click(Location(-135, 31))
    click(Location(-432, 92))
else:
    click(Location(-159, -13))
    click(Location(-162, 39))
    wait(2)
    type(Key.BACKSPACE)
    wait(1)
    type("44.07_Social Work")
    click(Location(-280, 439))   # Save file

() loops back to start a new search with the next set of parameters
   
VERSION 2

click(Location(-801, 92))
wait(2)
type("44.07")
wait(1)
click(Location(-525, 361))
type(Key.ENTER)
wait(10)
r = Region(-937,209,142,50)
if findAll("Report-cannot-be-completed-v2.png"): 
    click(Location(-384, 347))
    wait(2)
    click(Location(-327, -14))
    click(Location(-135, 31))
    click(Location(-432, 92))
else:
    click(Location(-159, -13))
    click(Location(-162, 39))
    wait(2)
    type(Key.BACKSPACE)
    wait(1)
    type("44.07_Social Work")
    click(Location(-280, 439))   # Save file
    
() loops back to start a new search with the next set of parameters

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