June 16, 2011

Check an alert dialog box and the text from it

In this post I will try to describe step by step how to create a function which checks for a dialog box and will also click on the button within it:




  Firstly we will create a class which we'll be calling on our need:

' creating the generic function
Public Function DialogBox
Set DialogBox = New QTPDialogBox
End Function


' defining the class
Class QTPDialogBox
Public Function CheckDialogBox (obj_DialogWindowId, obj_DialogWindowStyle, obj_StaticWindowId, obj_StaticText)
' defining the Dialog object's properties
Set obj_Dialog = Description.Create  
obj_Dialog ("micclass").value = "Dialog"
obj_Dialog ("nativeclass").value = "#32770"
obj_Dialog ("text").value= "Microsoft Internet Explorer"
obj_Dialog ("window id").value= obj_DialogWindowId
obj_Dialog ("windowstyle").value= obj_DialogWindowStyle