Retrieving Child Objects

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"

Next

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博客 ” ,链接:http://blog.itpub.net/16792402/viewspace-567244/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/16792402/viewspace-567244/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值