Object Repository and Descriptive Programming in QTP

Pre Requisites: Basic of OOPS

Object Repository (OR) and Descriptive Programming (DP) are the two ways by which QTP recognize the objects present in your application under test (AUT).

First let see about OR, this is one of the greatest features that QTP has. You can easily capture all the objects from AUT and store it into QTP’s OR. During the play back QTP use this OR to identify the object on which the action is to be performed. Here QTP take care of all the object and it properties, you have a very good UI to edit an existing OR.

Let us look at an example Google Search button present in the Google’s home page.

We recognize the search button as below.

The same is stored into QTP OR as shown below.

So QTP use the properties of the object to identify each objects uniquely present in AUT.

The Description properties namely type, name and html tag are the mandatory properties used to identify the objects. If more than one object has all the three properties same then it uses other properties (assistive properties) of the object to identify the correct object.

What if there are more than one identical objects in same web page or window?

QTP can use the following types of ordinal identifiers to identify such objects:

  • Index. Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description.
  • Location. Indicates the order in which the object appears within the parent window, frame, or dialog box relative to other objects with an otherwise identical description.
  • CreationTime. (Browser object only.) Indicates the order in which the browser was opened relative to other open browsers with an otherwise identical description.

The ordinal identifier assigns the object a numerical value(index starts with zero) that indicates its order relative to other objects with an otherwise identical description (objects that have the same values for all properties specified in the mandatory and assistive property lists). This ordered value enables QuickTest to create a unique description when the mandatory and assistive properties are not sufficient to do so.

Below screen shot shows the Ordinal identifier value for the browser object.

Now to click Google Search button, you start from the browser hierarchy.

Browser (“Google”).Page (“Google”).WebButton (“Google Search”).Click

Now we are able to perform actions on the objects present in OR,then why DP ?

DP is a way in which you describe the object by writing your own code or script,instead of storing the objects in OR.

QTP records the properties of the objects at the time of recording and stores in OR, during playback it compares the properties of those in OR with run time objects and perform action on them. But what if the object is a dynamically generated during run time?.Let me give a situation where OR will not help you to identify an object. If you want to close all opened browser automatically before you start executing your scripts, it is not possible to store all the opened browser objects into OR. So this can be solved by using OR and regular expression.

Here in DP you have option to define the properties of objects in the script itself. There are two ways by which you can define your objects.

In first method, you can describe an object directly in a statement by specifying property:=value pairs describing the object.

The same Google search button present in OR can be described by code as

Browser(“google”).page(“google”).webbutton(“name:=Google Search”,”type:= Submit”).click

In above statement Browser,Page are identified from OR webbutton is identified from DP,so the webbutton need not to be captured and stored into OR.So here we described an object with property and value pair, first property is name which has value as Google Search and another property is type which has value of Submit.

Second way to define a DP object is by using the Description object,You start by defining an object for example

Set mygooglesearch = Description.Create()

Then you declare the property name and value pair for that object

mygooglesearch(“name”).value =”Google Search”

mygooglesearch(“type”).value =”Submit”

Now the above object can be used in the script instead of the object present in OR as


Now to release the object and to free the memory,set that object to Nothing

Set mygooglesearch = Nothing

NOTE: When using programmatic descriptions from a specific point within a test object hierarchy, you must continue to use programmatic descriptions from that point onward within the same statement. For example

Browser(mygoogle).page(“google”).webbutton(“Google Search”).click is invalid because once you start using DP you can’t come back to OR for that statement.

Browser(mygoogle).page(mygoogle).webbutton(mygooglsearch).click is a valid statement

What are the other advantages of DP?

  1. Getting Object collections.
  2. If same object appears in different page/window then instead of capturing the object in every  page/window use one DP object.

Look at this example on how to use DP to close all browser.


This post explains  how QTP identifies objects and how to handle dynamic object using DP. OR the way in which QTP automatically stores the object, on the other hand DP is the way how we store the objects. DP is same as declaring a variable and assigning a value to it,here instead of value we assign object properties to the declared object.

29 thoughts on “Object Repository and Descriptive Programming in QTP

  1. Sir,

    I have one question:
    First QT will use Mandatory properties, then assistive properties to identify the object, if it is unable to find the object that matches with the learned description, or if it finds more than 1 object which fits the description then it goes for Smart Identification(if enabled).
    Still if it cannot identify that unique object, it will use the learned description plus the ordinal identifier to identify the object, if still QT cannot identify the object, then it stops the run session and displays run error message..

    Am I correct in understanding SI mechanism. If I am wrong, Please correct me…!

  2. Your are right,but ordinal identifier are mainly used when QTP finds more than one unique object, If it finds more than one object it checks for ordinal properties,if the ordinal identifier is not unique then it throws error saying more than one object matches the properties.

  3. You said: but ordinal identifier is used only when if QTP finds more than one unique object,it is not used to identify an object

    Let me clarify that the ordinal identifiers can be used even if there is only a single object present. How can it not be used to identify the object? You can simply use an index property and not use any other property to identify all the objects you need. Its not a good way, but your statement is completely misleading.

  4. QTP uses Ordinal Identifier only if there are more than one object matches the description,you can not user ordinal identifier for a unique object.

  5. Hi Dhanasekar,

    Thanks for the interesting information on DP in QTP. I worked on WinRunner and trying to catch up on QTP as I need to automate a webbased application. I tried the regular expression in OR to overcome the dynamic objects problem that is,

    My web page is generating a Frame dynamically (for example bottom, bottom_1, bottom_2 etc) and I used regular expression(bottom.*) to the name property in OR to recognize the object. For some reason its not working at all. Then I tried DP (with my minimal knowledge)and still no luck.
    The following is my code and Can you please help me in this regard
    web page has a resultset displayed in a table on a Frame( this is the dynamic object)

    Dim myChk
    Dim myChk_Edit
    Set myChk=description.Create
    Set myChk_Edit=description.Create
    msgbox myChk(“name”)

    Thanks inadvance

  6. Hi Dhanasekhar,

    Please help me a way to Parameterize links in QTP. I hav posted the same question earlier and for some days I didn’t get any answer and finally the question got deleted. I was littl disspointed as I am a good follower of this blog I had expectations then…


  7. Hi Dhanasekar,

    I am new to QTP.I am trying to automate the search functionality.
    My Browser page name changes everytime i search a term.

    This is a part of my code:

    For i=1to 5
    Browser(“Customize Your Settings”).Page(“Ringtones, Mobile Games,”).WebList(“group”).Select category
    Browser(“Customize Your Settings”).Page(“Ringtones, Mobile Games,”).WebEdit(“keywords”).Set keyword
    Browser(“Customize Your Settings”).Page(“Ringtones, Mobile Games,”).WebButton(“search”).Click

    How can i use regular expressions here?

  8. Hi friends

    i am new for this forum. i am a manual tester. now i trying QTP and Load Runner. in QTP i have some problem. in beneath i will explanied my queires , pls solve my Queries , for the last two day i tried for that

    1. in my project is the web based application. In the Application is having 5 tabs ( news , forum, Community, profile,and contact) i have tested 4 tabs expect community

    Because in the community tab , whenever i clicked the community , it has displayed different people names, People name has changed dynamically
    In QTP , the recording time it captured one people name, but in the Running time , people name has changed in the page , so i am getting the “cannot be displayed the object ” Error Message in QTP, how can i overwhelmed this problem. pls tell me the possible solution

    tell me the way to resolve my problem through Object REspoitory or Descriptive Programming


    Alagar samy.K

    1. Alagar,

      Simply you can use DP and find the quick solution to this.

      Lets say you have name which change dinamically then you can create the code with refrence to below code i.e.
      Dim myChk_Edit
      Set myChk_Edit=description.Create
      msgbox myChk(“name”)

  9. @samy,

    I’m assuming that people names in the Community tab are mentions in a webtable. If so, you can write VBScript code to get the data from the table rows and columns. Use this code inside a for loop to get cell data from all rows/columns.

    i.e. You can use VBScript functions (for WebTable object) like GetCellData, GetChildItem, ChildItems, ChildObjects, ChildItemCount, RowCount, ColumnCount in order to write the required code.

    Usage of these functions will be as follows.
    Browser(“welcome.*”).Page(“Introduction Page.*”).Frame(“Members Info”).WebTable(“Member Name”).GetCellData(iRowNo,iColNo)

    Hope this helps


  10. @Dhanasekar,

    Hi Dhanasekar,
    I wanted to know how we can create and destroy an object at runtime. What I’m aiming is to store object information as a string
    i.e. strFirstName = “name:=FirstName,html tag:=Input,Index:=0”
    then create object at runtime, use it, and then destroy the object.
    Set objName = Browser(strBrowser).Page(strPage).Frame(strFrame).WebEdit(strFirstName).Object

    Then use it as,
    objName.Set “John”

    I want to know how to destroy this object.

    Please suggest whether this will improve/decrease the performance of the script.

    I would really appreciate if you could CC the reply to yogi_teens@yahoo.com


    1. @ Yogesh
      You can release the object by setting into Nothing.
      Set objName = Nothing ‘ Release the object
      I have updated this in the post as well
      Dhanasekar S.

      1. Thank you so much.

        I tried this approach. Its a bit slow than runtime object identification using DP. but still significantly faster than our earlier approach.


        1. DP will be faster than OR,since you have all objects are available in your script and no need to scan through OR.
          Also we set to Nothing to release the objects,I don’t know any other way to release the object.
          Dhanasekar S.

    1. I don’t know the correct answer,but I feel it doesn’t matter for QTP. All it needs is it should be given with set of properties so that it can identify the object in AUT. that can be from OR or DP

  11. Hi,
    thanks for this informative post… i am having a problem with web check boxes and will be very greatful if u guide me in this regard, the AUT’s web page has 100+ check boxes and i dont want to add all of them to my OR and they are identical the only thing that uniquely identify them is their Index (Ordinal Identifier). Now i wanted to ask that can i use Ordinal identifier in my descriptive programing to check any check box on run time. like we can identify any object in DP by its Test Object Properties… Plz Comment How is it possible


  12. I have one query dhanasekars ,

    I have started running a window based application in QTP for my project and I am not able to resolve the error “cannot found object” to identify the objects . I tried through object repository , using object and run the maintainence mode to fix and whatever little knowledge I had to fix it but still nowhere. Can you please help me out by letting me know the step to initiate to fix the problem as I am really new to the tool .

    Thanks in advance!

  13. sir, how to handle objects in descriptive programming whenever objects are dynamically changing during UAT..actually my doubt is whenever objects dynamically changes in normal programming we go to object repository and change the object properties…at that time object information is available in object repository ..so we can easily modified but in case of descriptive programming object information is not stored in object repository …….. At that time on the spot how to handle objects……… could you please revert me back

  14. Hi

    I am a beginner of QTP, I am facing an issue with record and play method, the problem is when I recording the windows based application for instance I used flight application QTP did perfect recoding and identify an object and stored in OR as well.

    Q. When I copy the record generated code and paste it in to another test expert view page and then I tried to run it, QTP throws an error saying that an object not found in the OR.

    so can you please tell me how to resolve this.

    Thank you very much in advance


  15. Hi……i have a question like, i have webtable with row #2, column #3, in that dynamically changing webedit boxes are there (in that particular 2nd row an 3rd column), how to get that changing webedit boxes count,
    Please give the appropriate Ans ASAP, waiting for reply

  16. Hi,
    I am new to QTP.

    Why below code is not working? I am trying to pass the pageName dynamically

    Browser(“Browser”).Navigate linkURL
    pageName = Browser(“Browser”).Page(“micclass:=Page”).GetROproperty( “title” )
    Browser(“Browser”).Page(pageName).WebEdit(“Write something…”).set(msg)

    Please help me on this!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s