首页 > Linux操作系统 > Linux操作系统 > Retrieving Child Objects

Retrieving Child Objects

原创 Linux操作系统 作者:ipqiaojj 时间:2009-03-14 10:19:37 0 删除 编辑

Retrieving Child Objects

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:

Set MySubSet=TestObject.ChildObjects(MyDescription)

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

       Checkboxes(Counter).Set "ON"


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:

  • an image with the name Apple
  • an image with the name UserName
  • a WebEdit object with the name UserName
  • an image with the name Password
  • a WebEdit object with the name Password

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:

WebEdit("Name:=UserName", "Index:=0")

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.

WebElement("Name:=UserName", "Index:=0")

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博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录


  • 博文量
  • 访问量