Monday 19 August 2013

Get number of objects Individually on web page In QTP



Function GetAllSpecificControls(Page, MicClass)
    Set Desc = Description.Create()
    Desc("micclass").Value = MicClass
    Set GetAllSpecificControls = Page.ChildObjects(Desc)
End Function

Function GetAllEdits(Page)
    Set GetAllEdits = GetAllSpecificControls(Page, "WebEdit")
End Function

Function GetAllButtons(Page)
    Set GetAllButtons = GetAllSpecificControls(Page, "WebButton")
End Function

Function GetAllLinks(Page)
    Set GetAllLinks = GetAllSpecificControls(Page, "Link")
End Function

Function GetAllImages(Page)
    Set GetAllImages = GetAllSpecificControls(Page, "Image")
End Function

Function GetAllcheckbox(Page)
    Set GetAllcheckbox = GetAllSpecificControls(Page, "webcheckbox")
End Function

Function GetAllweblist(Page)
    Set GetAllweblist = GetAllSpecificControls(Page, "weblist")
End Function

'call these functions individually


Set oPage = Browser("creationtime:=0").Page("title:=.*")

MsgBox "Number of Edits: " & GetAllEdits(oPage).Count
MsgBox "Number of Buttons: " & GetAllButtons(oPage).Count
MsgBox "Number of Links: " & GetAllLinks(oPage).Count
MsgBox "Number of Images: " & GetAllImages(oPage).Count
MsgBox "Number of Checkboxes: " & GetAllcheckbox(oPage).Count
MsgBox "Number of Weblists: " & GetAllweblist(oPage).Count

No comments:

Post a Comment