Retrieving child objects

Relevant for: GUI actions, scripted GUI components, and function libraries

You can use the ChildObjects method to retrieve all objects located inside a specified parent object, or only those child objects that fit a certain programmatic description. To retrieve this subset of child objects, you first create a description object, and then you add the set of properties and values that you want your child object collection to match using the Description object.

Note: You must use the Description object to create the programmatic description for the ChildObjects description argument. You cannot enter the programmatic description directly into the argument using the property:=value syntax.

After you build a description in your description object, use the following syntax to retrieve child objects that match the description:

SetMySubSet=TestObject.ChildObjects(MyDescription)

Example:  

The statements below instruct UFT One to select all of the check boxes on the Itinerary Web page:

Set MyDescription = Description.Create()
MyDescription("html tag").Value = "INPUT"
MyDescription("type").Value = "checkbox"
Set Checkboxes = Browser("Itinerary").Page("Itinerary").ChildObjects(MyDescription)
NoOfChildObjs = Checkboxes.Count
For Counter=0 to NoOfChildObjs-1
	Checkboxes(Counter).Set "ON"
Next

In the run results, square brackets around a test object name indicate that the test object was created dynamically during the run session using the ChildObjects method or a programmatic description.

For details on the ChildObjects method, see the Common Methods and Properties section in the UFT One Object Model Reference for GUI Testing.

To learn more, see Programmatic descriptions.