Micro Focus QTP (UFT) Forums
Child Objects method not fetching the count of links - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Child Objects method not fetching the count of links (/Thread-Child-Objects-method-not-fetching-the-count-of-links)



Child Objects method not fetching the count of links - Shwethareddy - 10-24-2012

Hi,

Have written the below code to click on a link fetch the links under that webpage. where Site Search is a link name and trying to get all the links under Sitesearch page,with the below code.

lnknam="Site Search" 'passng thru a var as i got to parameterize the test

Code:
'Link Object
Set alllink=description.Create
alllink("micclass").value="Link"
alllink("name").value=lnknam


Browser("title:=.*","micclass:=Browser").Page("title:=.*").Link(alllink).Click
Set lnk=Browser("title:=.*","micclass:=Browser").Page("title:=.*").ChildObjects(alllink)
msgbox lnk.count

lnk count value is 1 n again results in Sitesearch, but i want to get all the Likns under SiteSearch webpage.Plz let me knw for any corrections in the above code.

Thanks in Advance
Shwetha


RE: Child Objects method not fetching the count of links - dillip.kumar1985@gmail.com - 10-24-2012

Code:
set objLink=description.create
objlink("micclass").value="Link"
set obj=Browser("title:=Google.*).page("title:=Google").childobjects(objLink)
msgbox obj.count



RE: Child Objects method not fetching the count of links - Shwethareddy - 10-25-2012

This works fine but as mentioned i want to include Link Click first and then pass the link value and get count of the childobjects under that


RE: Child Objects method not fetching the count of links - sshukla12 - 10-25-2012

Hi,

Try to use the below code:

Code:
lnknam="Site Search" 'passng thru a var as i got to parameterize the test

'Link Object
Set alllink=description.Create
alllink("micclass").value="Link"
alllink("name").value=lnknam


Browser("title:=.*","micclass:=Browser").Page("title:=.*").Link(alllink).Click
Set allink=Nothing
Set alllink=description.Create
alllink("micclass").value="Link"
Set lnk=Browser("title:=.*","micclass:=Browser").Page("title:=.*").ChildObjects(alllink)
msgbox lnk.count


Regards,
Sankalp