← Back to team overview

sikuli-driver team mailing list archive

[Question #257604]: Sikuli/Python: Proper Exception Handling

 

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

Here's my script structure:

    Method1()
    Method2()
    Method3()
    Method4()
    Method5()
    Method6()
    FoundException() #returns True/False
    
    BetaMethod()
    #calls Methods 1-3: This closes the target app if already open, opens the app, sets it up for testing
    
    while(exception == False)
    #call methods 4-6: this runs the testing until an exception is encountered
    if(FoundException): exception == True #then the loop is broken

I'm using try/except to catch exceptions. An exception can be any visual cue like a required button not appearing, or an unexpected button appearing, etc. At the moment, on exception I am calling BetaMethod() to restart the program and start from there. Is that the right approach?

For example- in Method1(), 
try: open the app, 
on exception: BetaMethod()

Is this the right approach? What can I do to make it better so that on exception I take some sensible steps?

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