Sunday, September 22, 2019

13.3 ChildObjects Method


What is the ChildObjects Method ?

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.

The objects contained in a window or frame are textbox, combo box and link. The window or frame is the Parent Object and the frame or textbox are the ChildObjects.

Syntax – object.ChildObjects(Description) – Description is required for Mobile ADD In and optional for all others.

Points To Remember

      1. Insight Objects do not support ChildObjects method
      2. Android objects are supported and related properties are supported – class, nativeclass, resourceid, text

1. The following script gets the name of all the links from a page -:

Dim oDesc
Set oDesc = Description.Create
oDesc("micclass").value = "Link"

'Find all the Links
Set obj = Browser("Math Calculator").Page("Math Calculator").ChildObjects(oDesc)

Dim i
'obj.Count value has the number of links in the page

For i = 0 to obj.Count - 1                              
   'get the name of all the links in the page
   x = obj(i).GetROProperty("innerhtml") 
   print x 
Next



2. The following script gets the number of Checkboxes with the HTML tag as INPUT and sets all those checkboxes as ON.

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


No comments:

Post a Comment