Types of Objects

There are 2 types of objects:
1.    Test objects (TO)
2.    Run – time objects (RO)

Test Objects: Test objects are QTP defined classes used to represent the various objects in the application under test (AUT)
Runtime Objects: Run time objects are the actual AUT objects which a Test Object refers/points to during test execution.

Comprehending the difference between these two object types is very important. Consider two cars; Car A and Car B. QTP would represent both cars using a Car Test object in the script. In addition, each Test Object also provides methods and properties used to interact with its associated Run-time object. For example, methods like Start, Run and stop would be useful methods provided by a Car Test Object.

TO Properties:
 

Test Object properties are those properties that QTP maintain in the OR for identifying a Run-time object during test execution. QTP allows enumeration of all TO properties using GetTOProperties  method. GetTOProperty and SetTOProperty are used to read or modify the TO property values respectively.

Working with Test Object Properties

1)    Retrieving Test object property value one by one
 

Add that object to OR.
 

Msgbox <obj hierarchy>.GetTOProperties(“property name”)
 

Ex:  msgbox Dialog(“Login”).GetTOProperties(“text”)
     Msgbox Dialog(“Login”).GetTOProperties(“native class”)
       Msgbox Dialog(“Login”).GetTOProperties(“is owned window”)
       Msgbox Dialog(“Login”).GetTOProperties(“is child window”)
   
2)    Retrieving Test object all property values at a time

Add required object to OR. (Ex: Add Sample application Dialog window to OR )

‘Get the required object
Set obj=Dialog(“Login”)

‘Get the total TOProperties collection for dialog object
Set TOProps=obj.GetTOProperteis()

‘Loop for all property
For i=0 to TOProps.Count – 1
    propertyName=TOProps(i).Name
    PropertyValue=TOProps(i).Value
    isRegularExp=TOProps(i).RegularExpression
msgox “Property name   “&propertyName&”  Property value  “&propertyvalue&”                                                                 
regularexp “&isRegularExpr
           Next
   
3)    Changing Test Object Properties at run time.

Syntax: 


<obj hierarchy>.SetTOProperty “property name”,”new property values”

Add required object to OR. (Ex: Add Sample application Dialog window to OR )
Dialog(“Login”).SetTOProperty “text”,”Login screen”
Msgbox Dialog(“Login”).GetTOProperty(“text”)

Note: If object properties are changing at run time then we are set the property.
Ex: Start button to Stop button.
       Play button to Pause button.

Working with Run-time Object Properties

4)    Retrieving Run-time object property vlaues during test execution

Syntax: <obj hierarchy>.GetROProperty(“property name”)


Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com