HOW TO CHECK ALL THE LINKS DYNAMICALLY?

Simons Hood

Total Post:70

Points:494
Posted by  Simons Hood
 1162  View(s)
Ratings:
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.

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to check all the links dynamically?

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!