Search This Blog

Tuesday, September 21, 2010

Capturing the screenshot in case of error

The following piece of code can be inserted as a fucntion call in you recovery scenario. If you set the occurence as "On Error", it will take the screenshot of your screen in the event of an error. This is helpful in understanding what exactly happend before the recovery scenario was triggered.

Dim filename

Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FolderExists("D:\Automation\Results\Screenshots")= "False" Then
FSO.CreateFolder("D:\Automation\Results\Screenshots")
End If

timenow = now
timenw= split (timenow, " ")
filename = RecipeNo &"_"&timenw(1)&".png"
filename = Replace(filename,"/","")
filename = Replace(filename,":","")
filename = "D:\Ranger Automation\Results\Screenshots"&"\"&filename
Desktop.CaptureBitmap filename,true
Reporter.ReportEvent micFail,"image","<"

No comments:

Post a Comment