Thursday, January 15, 2015

Child Objects and Child Items in QTP(Quick Test Professional) and Its Returning Values

What are Child Objects:The Objects like TextBox ,ComboBox, CheckBox, Links etc. contained in a Frame or Window or any WebPage are known as Child Objects.

For the use of the ChildObjects we need to have the Description of the objects, and with the help of description we will be able get the command over the objects present on the window ,and then we can play with the objects as per the Test Script Demands.

Returning Value of ChildObjects: It returns the collection of Objects of any specific Property Value pair.

Example and Syntax of ChildObjects :

Dim oDesc
Set oDesc = Description.Create  'Creating a description object
oDesc("micclass").value = "WebCheckBox"

'Find all the CheckBoxes
Set obj = Browser("abc").Page("abc").ChildObjects(oDesc)

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

What are ChildItem:ChildItem method is to access child objects from a web table cell in web table object without using description object. In short there is no relation of the Child object to child Item

ChildObject uses Description to get the Collection of the objects and ChildItem is to access the objects in the webTable

What is Returns: It Returns a Test Object from the Web Table Cell by Type and Index

Example and Syntax of ChildItem Method:

Browser("abc").Page("abc").WebTable("test").ChildItem(Row, Column, MicClass, Index) .