← Back to team overview

sikuli-driver team mailing list archive

[Question #234402]: While not exists Loop Throwing Error When I Have Else Condition at the End

 

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

I want to do a while loops that says while you don't see an error message, run this workflow. Else, if you do see the error message, take a screen shot of the entire screen.

When I add the else code in, the IDE throws a weird exception or error.

Here's the code in my script:

while not exists("ErrorScreenshot.png"):          
           click(a)
           rightClick(a)      
           #doubleClick(b)
           click(b)
           doubleClick(Pattern("1374609778702.png").similar(0.57))
           type(username)
           type(pwd)
           click("1374609885172.png")           
           wait("1374609994953.png", 70)
       
           click("1374610198940.png")       
           click("1374699689215.png")
           print username, pwd
           
      else:
           screen = Screen()
           file = screen.capture(screen.getBounds())           
           print("Saved screen as "+file)

Here's the error message i get when I uncomment the else conditon:

[error] script [ *ModifyCredReadFromConfig ]] stopped with error at line --unknown--
[error] Could not evaluate error source nor reason. Analyze StackTrace!
[error] IndentationError: ('unindent does not match any outer indentation level', ('C:\\Users\\Sikuli\\AppData\\Local\\Temp\\sikuli-6590832730376844871.py', 40, 6, ' else:\n'))


Any ideas what is wrong? Is an else condition not allowed with while not exists?

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