Ask a Question

On Error Call

g_kucharski
Occasional Contributor

On Error Call

Hi,

I am using VBS to script my scenarios. TC works on remote machine and reports me in realtime with emails cases when results are different from expected. I run about 300 cases daily and want to concentrate on important cases only.



I have problems with cases when TC fails to get throgh the whole scenario - test fails with an error (overlapping windows, no object found or tested application fails with a fatal error). Of course there is info is the tests' log, but I created mail reports to avoid reading throgh 300 cases logs. Which cannot be reached while tests are going on anyway (12 hours or so, 5 am - 5pm).



Is there a way in TestComplete to force calling an 'error procedure' when there is error logged instead stopping / continuing the test?



regards



Greg



1 REPLY 1
g_kucharski
Occasional Contributor

VBS does not suport ErrorHandlers, and only options available are on Error ResumeNext and On Error Goto 0. However there is a solution - EventHandlers which I ignored so far:



http://support.smartbear.com/viewarticle/55502/



I added EventHandler 'OnLogError':




'USEUNIT CommonScripts



'CommonScripts unit contains Subs and Functions used by other units, including MailErr and KillThemAll Sub



Sub



GameOver_OnLogError(Sender, LogParams)



 



'Take a screen shot of the active window.



Set Wshshell=CreateObject("Word.Basic")



WshShell.sendkeys"%{prtsc}"



'Send Keys seems to fail without a Proper Delay



Delay(500)



 



 



'Create PictureObject from Clipboard



Set PicObj = Sys.Clipboard



Call PicObj.SaveToFile("C:\ErrorPics\LastError.png")



 



'Send Email about error with prontscreen attached



Call MailErr(LogParams.AdditionalText, "GAME OVER - " & LogParams.MessageText)



 



'Kill all trash processes that might remain after error was logged



Call KillThemAll



 



'Stop



 



Runner.Stop(True)



End Sub


cancel
Showing results for 
Search instead for 
Did you mean: