What is Descriptive Programming in UFT??

Spread the love
  • 2

What is Descriptive Programming in UFT?

Entering / Providing objects information directly into the test script is called Descriptive Programming.When QTP/UFT records any action on any object,it tries to identify the object with some of its properties. And stores them in object repository. Later point of time , during execution, it takes reference from it and tries to find out the object in the application and  perform set of operations.
So, if an object is not present in the object repository, QTP/UFT can not identify the object and perform operation on it.
With the fast development of application and agile way of developing software advocates more about descriptive programming. Imagine we need to design our test script without the GUI. Yes!! it is possible. Descriptive programming provides information to QTP/UFT bypassing object repository. The same object information is passed to QTP/UFT so that it can identify the object.

Lets think about a person whom we don’t know. When we meet for the first time, we create an image of that person. Like name, tentative age,gender,height,if the person wear specs or not etc.  For us to remember that persons these are enough. we will be able to identify the person in our next meet by using our stored properties of that person. These are mandatory properties. There are some other things we can notice. We may also notice the shirt color, trouser color, some more details. They are assistive properties. The help to identify the person uniquely. But they may change.

Likewise if we need to identify a textbox, the first thing we will be looking is the name or id. This will help me to identify the textbox.In this method of script creation, we no need to have Object Repositories.
But assume that we have a special application which is dynamic in nature. So with the stored object description QTP/UFT will not be able to identify the objects. Say after loggin we have a welcome message say Welcome <<UserName>>. Upon clicking on the username it will navigate to the actual page.
This will work fine if the same user logs in but fails when another user logs in as the stored object description does not match to the application object.So we need to find an another way of coding.
This is called Descriptive programming.

In real world if the person says I want to meet you and I will be seating some coffee hose, table number-2. I will be in red shirt. Then we will not try to find the person, directly go to that coffee house and go to table no-2. Now if I see a person with red shirt , we will get the person. Is not it??

So , in this method we provide information about the object to QTP and request it to perform search operation and carry out tasks.
In real project if the GUI is not available or the project size is getting bigger(OR will also bigger), we use descriptive programming.

a) Descriptive Programming based Test scripts are faster in execution than Repository based Test scripts.
b) Scripts are portable (we can run these scripts from any machine easily)
c) Maintenance is easy (less amount of resources)
d) We can start Test Execution process even though Application is not ready.

Descriptive programming is basically 2 types.
1. Static Programming
2. Dynamic Programming

Static Programming

In this style of script generation, we provide objects information directly into the script.

Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"
dialog("text:=Login").Winedit("attached text:=Agent Name:").Set "asdf"
dialog("text:=Login").Winedit("attached text:=Password:").Set "mercury"

1. Dialog, WinEdit and WinButton – Test Objects
2. text, attached text – Property names
3. Login, Agent Name:, Password:, OK – Property values or Logical Names of the Object
4. Activate, Set, Setsecure, Click – Methods
If we feel one property information is not sufficient for recognizing the object uniquely, then we can provide more properties information by separating with commas.
Note 3:
If we want to get objects information (Test objects, properties and values), we can use object spy feature. This feature is available in Tools Menu, in local repository and in repository manager.
If we want maintain ‘Objects information’ in centralized location then we can use Constants.
Creating Constants:
Const Login=”text:=Login”, Agent=”attached text:=Agent Name:”
Const Pwd =”attached text:=Password:”, Ok=”text:=OK”
Note: we can declare no of Constants in a line by separating with Camas (,), if we take other line then we have to use Const Statement again.
Creating a Library file
Place Constants in Notepad and save as .vbs file
Associate the Library file to QTP (File->Settings->Resources-> Click add (+) icon-> Browse path of the Library file->Click Apply and click Ok buttons
Otherwise, we can load the library file during run-time
ExecuteFile “Path of the Library file(.vbs)”
After that create the Test Script using Constants
Creating the Test Script using Constants:

Invokeapplication "C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe"
Dialog(Login).Winedit(Agent).Set "asdf"
Dialog(Login).Winedit(Pwd").Set "mercury"

If we maintain Object Information in the centralized location, then we can handle modifications easily.

Dynamic Programming:

In this style of script generation, first we create description objects, provide properties information and use description objects in the test script.
Creating Properties Collection Objects

Set oLogin=description.Create
Set oAgent=description.Create
Set oPassword=description.Create
Set oOk=description.Create
//Entering Properties Information into Objects
oAgent(“attached text”).value=”Agent Name:”
oPassword(“attached text”).value=”Password:”
//Generating Tests using Properties collection Objects
Invokeapplication “C:Program FilesHPQuickTest Professionalsamplesflightappflight4a.exe”
Dialog(oLogin).Winedit(oAgent).Set “asdf”
Dialog(oLogin).Winedit(oPassword).Set “mercury”

Note1: Create Description objects and put into one library file, by associating that library file, we can generate tests.
Note2: Dynamic programming is some difficult in preparation than static programming but maintenance is very easy.
In this style of script creation also, we can maintain Objects information in the Centralized location by putting collection objects in a Library file.
Well,Here is the technique to write descriptive progranning…the main boost of my secrets…
Please follow the threads..

Descriptive Programming is an advanced concept of QTP coding. Testers can handle the application without using the OR by implementing the Descriptive programming.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 2


  1. Hi Animesh,

    I have a question to you regarding an issue we faced today.
    Scenerio is:-
    1)We have an object as WebElement whose value is dynamically changing.For example,say i want to retrieve a policy number.When i added that object and retrieve with GETROPROPERTY,it is retrieving only one value which is added in the OR.For the next iteration it is throwing an error saying cannot find object.
    In this scenerio, we use regular expression,but using that it didnt helped.What are the other way to solve this issue?Please help me regarding this.



Please enter your comment!
Please enter your name here