Jump to content
Sign in to follow this  
Barak3D

On Error Resume Next

Recommended Posts

Barak3D

Hi,

I'm kinda new to autoit but I did try to loopup this in the help file/the forum with no success.

Is there a command I could resume the script on errors so it won't stop the test flow in case of 1 simple error?

I'm a pretty expirianced QTP user. In QTP there's a command "On Error Resume Next".

The reason this is so crucial to me is that I make test scenarios with Autoit with UDFs I've made using DOM and right now when I run my script and there is 1 simple error the script stops and the whole process stops..

Thanks in advance :)

Share this post


Link to post
Share on other sites
Jos

there is no "On Error Resume Next" option in AutoIt3, but there are 2 things that can be set:

Catching errors running a program: Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error

Catching COm errors:

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler 

; This is my custom error handler 
Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   SetError(1); something to check for when this function returns 
Endfunc

:)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Barak3D

There is absolutly no way to continue the script run if an error occured?

For example, I built UDF to automate test in a website;

ClickOnImage("logon.gif")

InsertValue("userID","autoit")

InsertValue("passID","abc12345")

ClickOnObject("Enter")

VerifyPage("Example Auto It Page")

SelectFromDropDownList("Select1","This site")

InsertValue("Search","BMW")

ClickOnObject("Go")

now let say somewhere along the way an error occures (which is what I'm trying to find - bugs), I have a report handler I made, to tell me why one of these actions would fail(disabled button/not exist in page etc..) but the report is given in Consol and the test stops at that step and not continuing on.. there must be some kind of way :)

Edited by Barak3D

Share this post


Link to post
Share on other sites
weaponx

If you have your own error handler, place this at the top of your script Opt("RunErrorsFatal", 0) like Jos said.

If you are in a loop you can do this:

For $X = 1 to 10

$result = Ping("www.google.com")

If @ERROR Then ContinueLoop

MsgBox(0,"","Ping successful")

Next

Edited by weaponx

Share this post


Link to post
Share on other sites
Barak3D

If you have your own error handler, place this at the top of your script Opt("RunErrorsFatal", 0) like Jos said.

If you are in a loop you can do this:

For $X = 1 to 10

$result = Ping("www.google.com")

If @ERROR Then ContinueLoop

MsgBox(0,"","Ping successful")

Next

Thanks I'll try that

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.