QTP - Child Objects



The objects (text box, combo box, links) contained in the frame or window is known as child objects. Sometimes, we would be in a situation to get the properties of all the links in a webpage or to get the values of all radio buttons in a window.

In these circumstances, if we want to work on the child objects, we need to use description of objects using which we will be able to work on all the objects in a particular window/page. Descriptive programming will be dealt in detail in the upcoming chapter but the significance of this chapter is to understand child objects and its usage.

The following Script gets the name of the links from the website "www.easycalculation.com"

Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

'Find all the Links
Set obj = Browser("Math Calculator").Page("Math Calculator").ChildObjects(oDesc)

Dim i
'obj.Count value has the number of links in the page

For i = 0 to obj.Count - 1				
   'get the name of all the links in the page
   x = obj(i).GetROProperty("innerhtml") 
   print x 
Next

The Result is printed in the output window as shown below −

Print Console
qtp_object_repository.htm
Advertisements