Micro Focus QTP (UFT) Forums
Get total links visible on a webpage - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Get total links visible on a webpage (/Thread-Get-total-links-visible-on-a-webpage)



Get total links visible on a webpage - Sanjay_DP - 02-10-2011

Hi,

I tried fetching all the links on a webpage using the following code.

Code:
Set oDesc = Description.Create()
    oDesc("micclass").Value = "Link"
    Set ChildCount = Browser("name:=.*").page("title:=.*").ChildObjects(oDesc)
    num = ChildCount.Count

But it returns me links which are even not visible on the page. I would like to get only a set of visible links on the current page.

I tried using the "Visible" property as well but it reruns 0 objects.


RE: Get total links visible on a webpage - Rahull - 02-10-2011

Hi,

Try to find the "unique" property by comparing the visible link and non visible link using the getroproperty. Then specify the same in description.

--Rahul


RE: Get total links visible on a webpage - supputuri - 02-11-2011

Hi,

describe below property too.

Code:
oDesc("Visible").Value = "True"

And now try to run and let me know if it does not solve your issue.


RE: Get total links visible on a webpage - Sanjay_DP - 02-11-2011

Hi, It returns 0 objects if set:

Code:
oDesc("Visible").Value = "True"

Sad


RE: Get total links visible on a webpage - DinakarVadapalli - 02-11-2011

Code:
Set oBrowserDescriptions = Description.Create ()
oBrowserDescriptions("micClass").Value = "Browser"
oBrowserDescriptions("openedbytestingtool").Value = "True"
Set oPageDescriptions = Description.Create ()
oPageDescriptions("micClass").Value = "Page"
Set oBrowserObj = Browser(oBrowserDescriptions).Page(oPageDescriptions)
Systemutil.Run "iexplore"
Browser(oBrowserDescriptions).Navigate "www.google.com"
oBrowserObj.Sync
Set oBowserChObj = oBrowserObj.ChildObjects(oLinkDescriptions)
Set oBowserChObj = oBrowserObj.ChildObjects()
iChObjCnt = oBowserChObj.Count -1
msgbox iChObjCnt
For iCount = 0 to iChObjCnt
    If  oBowserChObj(iCount).GetROProperty("micclass") = "Link" Then
        If  oBowserChObj(iCount).GetROProperty("visible") = true Then
    msgbox oBowserChObj(iCount).GetROProperty("name")
    End if
    End If
Next



RE: Get total links visible on a webpage - Parke - 02-16-2012

visible is boolean so use = True with no quotes

Code:
Set oDesc = Description.Create()
oDesc("micclass").value = "Link"
'oDesc("visible").Value = True
Set childCollection = Browser("Google").Page("Google").ChildObjects(oDesc)
num = childCollection.count

msgbox "number of links = " & num

s = ""
For i = 0 to num - 1
    var = childCollection.item(i).GetROProperty("innertext")
    var_2 = childCollection.item(i).GetROProperty("visible")
    var_all = var & ": " & var_2
    s = s & vbcrlf & var_all
Next

msgbox s

on 2012-02-16. there are 40 links. 21 links have visible = True
Run the code with visible active and not active.

hth,


Parke