Jump to content

Recommended Posts

Posted

Hi

I have used other tools for doing GUI Testing, but I am relatively new with AutoIT.

Normally in a language like C# we have a Try.. Catch block as a Error Handling Mechanism

OR Like

onerror GoTo <Function> Mechanism

What do we have in AutoIT?

Eg. So let say i have a script with following lines

Dim $var1

Dim $var2

$var1 = ShellExecute("outlook.exe")

$var2 = WinWait("Outlooks","",10)

.....

......

Other script commands

What i need is that if any of the line fails like ShellExecute or WinWait it should stop script execution and execute Error Function or return with 1 as ExitCode. Is this Possible.??

What i tried was to add this line on top.

$oMyError = ObjEvent("AutoIt.Error","MyErrorHandling")

but it never executed the MyErrorHandling function, becuase WinWait is error for me as string "Outlooks" will not exist.

Please Guide.

Posted (edited)

You could experiment with @error and AdlibEnable... but you will also need logging to figure out where it fails

AdlibEnable("errorHandle")

...
...
...

Func errorHandle()
    If @error Then
        ConsoleWrite("Failure" & @CRLF)
        Exit 1
    EndIf
EndFunc

never tried it... worth experimenting

Lar.

Edited by LarryDalooza

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Posted

Ugh... AdlibEnable does not work how I imagined. I thought it ran after every line of code or 250ms, whatever happened first or some crap like that.

NEVERMIND anything I've posted here... nothing to see here... move along.

Lar.

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

  • 3 months later...
  • Developers
Posted (edited)

AdlibEnable("errorHandle")

^ ERROR

Stick to your own thread, learn to read before asking and when you really need to ask a question formulate the question in stead of posting these types of posts. Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...