The following code can be added in the recovery scenario as a function call. When the occurence is set to "On Error" it will check for any unknown window, if it finds this unknown window, it will click ok or cancel button or any other button which we are giving in the script. If there is not such unwindow and still the object expected by QTP is not visible, then it will also click Retry for the QTP error.
This is very important since we are handling here both application generated as well as QTP generated errors. You can also add the function for caputuring the screenshot here to make it an excellent looking Recovery Scenario.
Function UnknownWindow(Object, Method, Arguments, retVal)
Dim var
var=Array("&No","OK","Ok", "Cancel", "Close")
Set o_Desc=description.Create
Set o_Nobutn=description.Create
o_Desc("Class Name").value="Dialog"
o_Desc("ispopupwindow").value=True
If Window(o_Desc).Exist Then
Window(o_Desc).Activate
Arr_Count=Ubound(var)
For i= 0 to Arr_Count
o_Nobutn("text").value=var(i)
If Window(o_Desc).winbutton(o_Nobutn).Exist(0) Then
Enabled = Window(o_Desc).winbutton(o_Nobutn).GetROProperty("enabled")
If Enabled = "True" Then
Exit For
End If
End If
Next
Window(o_Desc).winbutton(o_Nobutn).Click
Else
QTP_Error
End If
End Function
'-----------------------------------------------------------
Public Function QTP_Error
count = 1
For Count = 1 to 2
Set WshShell =CreateObject("WScript.Shell")
Btncode = WshShell.Popup ("object is disabled", 1)
WshShell.SendKeys "{TAB}"
wait 2
WshShell.SendKeys "~"
Next
CloseApplication
ExitTestIteration
End Function
No comments:
Post a Comment