Thursday, June 4, 2009

Getting Child Objects in QTP?

Returns the collection of child objects contained within the object.

We can use description object to get all the objects on the page that matches that specific description. Suppose we have to check all the checkboxes present on a web page. So we will first create an object description for a checkboxe and then get all the checkboxes from the page

Dim obj_ChkDesc
Set obj_ChkDesc=Description.Create
obj_ChkDesc(“html tag”).value = “INPUT”
obj_ChkDesc(“type”).value = “checkbox”
Dim allCheckboxes, singleCheckBox
Set allCheckboxes = Browse(“Browser”).Page(“Page”).ChildObjects(obj_ChkDesc)

For each singleCheckBox in allCheckboxes
singleCheckBox.Set “ON”

Sub ChildObjects_Example()'The following example uses the ChildObjects method to find all the'list objects on a Web page, and then to select an item in each list.

Set oDesc = Description.Create()

oDesc("micclass").Value = "WebList"

Set Lists = Browser("Mercury Interactive").Page("Mercury Interactive").ChildObjects(oDesc)NumberOfLists = Lists.Count()

For i = 0 To NumberOfLists - 1

Lists(i).Select i + 1


End Sub

all the values are interpreted as regular expressions. To turn it off, use

oDesc(“Property1”).RegularExpression = False

type = checkbox
type = radio
class = weblist
class= webedit
class = image

in description object for list,textbox,image we can use micclass in description object

No comments:

Post a Comment