Home > DeveloperSection > Forums > How to check all the links dynamically?
Simons Hood
Simons Hood

Total Post:70

Points:494
Posted on    June-20-2013 2:00 AM

 VB Script VB Script 
Ratings:


 1 Reply(s)
 888  View(s)
Rate this:
Hi Expert,

The following thing I have to do using VBScript in QTP 10/11:

The VBScript opens one login page. After the login it counts the number of links in that page and then prints all the links. Afterwards it opens every link one by one.

I am having issues with finding all the dynamic links.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    June-20-2013 5:40 AM

Hi,

You can get all the links on a page by using the Page's (or Frame's) ChildObject method.

Set desc = Description.Create()
desc("html tag").Value = "a"
Set links = Browser("B").Page("P").ChildObjects(desc)
For i = 0 to links.Count - 1
    Print links(i).GetRoProperty("inner_text") & " => " & links(i).GetRoProperty("href")
Next
As for clicking them, that's a bit more complicated since after clicking a link you cause a navigation that invalidates the links object, you should either perform 

the ChildObjects each time (while keeping track of the index) or open the links in a different browser/tab.


Don't want to miss updates? Please click the below button!

Follow MindStick