Friday, 3 June 2011

How to count the number of link in a website using QTP?

To count the number of links in a web page, We can use ChildObjects to get the link collection, then retrieve the properties for example number of links or any other objects on page.

Dim oDesc, oAllLinks, iNumberOfLinks
set oDesc = Description.Create()
oDesc("micclass").Value = "Link"
Set oAllLinks = Browser("creationtime:=0").
Page("micclass:=Page").ChildObjects(oDesc)
iNumberOfLinks = aAllLinks.Count
msgbox iNumberOfLinks

No comments:

Post a Comment