Sign in to follow this  
Followers 0
jlei

IE.au3 try catch equivalent

3 posts in this topic

Is it possible to do something like a try catch in au3 script?

Basically I am using au3 for web test automation using the IE.au3 library, but it is cumbersome to manually set test assertion events. Right now I am picking places to pull out the source code and look for keywords of known fail areas.

But the other thing i thought of would be to use the @error reporting and just try block the whole script and catch after a function any time @error != 0 (from then on I would take a screenshot of where its at since it obviously failed)

This would greatly improve test assertion capability inand even give ie.au3 some test automation flavor.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

For COM objects in Autoit there is

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

Func ErrorHandler()
    $HexNumber = Hex($oMyError.number, 8)
    
    MsgBox(16, "CHYBA", "DoÅ¡lo k chybÄ!" & @CRLF & @CRLF & _
            "Popis chyby: " & @TAB & $oMyError.description & @CRLF & _
            "Win. popis:" & @TAB & $oMyError.windescription & @CRLF & _
            "Äíslo Åádku: " & @TAB & $oMyError.scriptline & @CRLF & _
            "Äíslo chyby: " & @TAB & $HexNumber & @CRLF & _
            "Objekt: " & @TAB & $oMyError.source)
    
    SetError(1)
EndFunc
Edited by Zedna

Share this post


Link to post
Share on other sites

Right... and in IE.au3 there is _IEErrorHandlerRegister() which allows you to either use your own handler like this one or a generic one written for IE.au3. In either case, with IE.au3 you must use _IEErrorHandlerRegister() to avoid losing other functionality (see the remarks in the helpfile for more info).

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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  
Followers 0