UFT/QTP – Descriptive Programming

When UFT learns an object in application, it adds the appropriate test objects to the object repository along with some description on how to identify that object. UFT cannot take action on an object until it is in the object repository.

Descriptive programming (DP) is used when we want to perform an operation on an object that is not present in the object repository. There are many obvious reasons why an object cannot be in the repository and also why we should use descriptive programming like –

  • When objects in the application are very dynamic.
  • When the Object Repository’s size is big, it results in poor Performance as the size of the Object Repository increases.
  • When the framework is built such that it has been decided not to use Object Repository at all.
  • When testers want to perform an action on the application at run-time without having the knowledge of object’s unique properties.

How to do Descriptive Programming?

There are two ways for writing code using descriptive programming.

  1. Using Description Objects
  2. Using set of properties and values directly in the statement

Using Description Objects

You can use the description object to return a properties collection object containing a set of property objects. A property object consists of a property name and value. You can specify the returned properties collection in place of an object name in a statement.

Example – Using description object we can set data into the Google search edit box –

‘Creating a description object

Set descObj = Description.Create()

descObj(“type”).value = “text”

descObj(“name”).value = “q”

descObj(“html tag”).value = “INPUT”

Browser(“Google”).Page(“Google”).WebEdit(descObj).Set “Automationtutorial.com”

Using set of properties and values directly in the statement

You can describe an object directly in a statement by specifying property:=value pairs describing the object instead of specifying an object’s name.

Syntax – TestObject(“PropertyName1:=PropertyValue1”, “PropertyName2:=PropertyValue2”, “…..”, “PropertyNameX:=PropertyValueX”)

TestObject –  Test object class like Browser, Page, WebEdit,Weblist, WebButton

PropertyName:=PropertyValue – The identification property and its value. Each Property:=Value pair should be separated by commas and quotation marks.

Example – Using Property:=Value pair we can set data into the Google search edit box –

Browser(“Google”).Page(“Google”).WebEdit(“type:=text”,”html tag:=INPUT”,”name:=q”).Set “Automationtutorial.com”

Child Objects

UFT provides the ChildObjects method which enables us to create a collection of objects. The parent objects preceeds ChildObjects.


Dim oDesc
Set oDesc = Description.Create     ‘Creating a description object
oDesc(“micclass”).value = “Link”

‘Find all the Links
Set obj = Browser(“Google”).Page(“Google”).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(“innertext”)
print x

Ordinal Identifiers

Descriptive programming is used to script based on ordinal identifiers which will enable UFT to act on those objects when two or more objects have same properties.


Dim Obj
Set Obj = Browser(“title:=.*google.*”).Page(“micclass:=Page”)

‘ Using Location
Obj.WebEdit(“name:=Test”,”location:=0″).Set “ABC”
Obj.WebEdit(“name:=Test”,”location:=1″).Set “123”

‘ Index
Obj.WebEdit(“name:=Test”,”index:=0″).Set “1123”
Obj.WebEdit(“name:=Test”,”index:=1″).Set “2222”

‘ Creation Time

Leave a Reply Cancel reply