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 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.
Once you have "built" a description in your description object, use the following syntax to retrieve child objects that match the description:
For example, the statements below instruct QuickTest 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
In the Test 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 more information on the ChildObjects method, see the HP QuickTest Professional Object Model Reference.Using the Index Property in Programmatic Descriptions
The index property can sometimes be a useful test object property for uniquely identifying an object. The index test object property identifies an object based on the order in which it appears within the source code, where the first occurrence is 0.
Index property values are object-specific. Thus, if you use an index value of 3 to describe a WebEdit test object, QuickTest searches for the fourth WebEdit object in the page.
If you use an index value of 3 to describe a WebElement object, however, QuickTest searches for the fourth Web object on the page regardless of the type, because the WebElement object applies to all Web objects.
For example, suppose you have a page with the following objects:
The description below refers to the third item in the list above, as it is the first WebEdit object on the page with the name UserName:
The following description, however, refers to the second item in the list above, as that is the first object of any type (WebElement) with the name UserName.
Note: If there is only one object, using index=0 will not retrieve it. You should not include the index property in the object description.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/16792402/viewspace-567244/，如需转载，请注明出处，否则将追究法律责任。