Barak3D Posted December 20, 2007 Posted December 20, 2007 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
Developers Jos Posted December 20, 2007 Developers Posted December 20, 2007 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 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.
Barak3D Posted December 20, 2007 Author Posted December 20, 2007 (edited) 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 December 20, 2007 by Barak3D
weaponx Posted December 20, 2007 Posted December 20, 2007 (edited) 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 December 20, 2007 by weaponx
Barak3D Posted December 20, 2007 Author Posted December 20, 2007 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")NextThanks I'll try that
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now