QTP – Create Object Repository (Local / Per-Action OR)

Object Repository is a collection of objects (its properties and methods), which can be referred in the automation script. There are two types of object repositories:

  1. Local Object Repository (per action OR)
  2. Shared Object Repository

Local Object Repository:

When a new test is created in QTP, it will be associated with an object repository and this is named as per-action / local object repository. This OR cannot be referred in the other tests / actions.

We will try to create an object repository and use in a test script.

  • Open QTP
  • Create a New Test (File –> New –> Test / Ctrl+N)
  • Save the test (File –> Save As –> Give a name / LoginScript)
  • Open Flight Sample application (Login screen)
  • Click Resources –> Object Repository (ctrl+R)



  • Click on the Add Object icon in the Object Repository screen
  • Mouse pointer will turn to a hand symbol
  • Click on the Objects which we need to add one by one(first click on the Agent Name: edit box)
  • Make sure that the application for which we need to create Object Repository should be maximized and available on the desktop


  • Once the objects are added to the Object Repository, we can see the added objects inside the OR as in the above picture

Change the logical names of each of the objects so that identifying the objects inside the script should be easier.

  • Click on the Cancel button in the Object Repository
  • On the right side, we can see the edit box (Object Properties) provided to edit the name of the object
  • Change the name to btnCancel – btn refers to “Button”
  • Change the name of the OK to btnOK
  • Change Agent Name: to wdtAgentName (wdt – WinEdit)
  • Change Password to wdtPassword

If we use naming convention such as wdt (WinEdit), btn (Button) it will be very much useful when there are a lot of objects to be captured in the Application Under Test. Below is the picture of updated Object Repository.


Let us try to create a LoginScript using this newly created Object Repository.

'Script "Login into the Flight application
'Author - Seetaram Hegde
'Copyrights - All rights reserved

SystemUtil.Run "C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\flight4a.exe","","C:\Program Files\Mercury Interactive\QuickTest Professional\samples\flight\app\","open"
Dialog("Login").WinEdit("wdtAgentName:").Set "admin"
Dialog("Login").WinEdit("wdtPassword:").Set "mercury"

The above script is not a recorded script but is written. So, follow the below steps to create the script.

SystemUtil.Run is a command used to open any application that is installed on the Operating System (Desktop)


SystemUtil.Run "file name", "directory of the application", "mode"

Directory and mode are optional


Type the “Dialog(“ then we can see the names of the dialog available in the object repository. Since here there is only one dialog, we will get only “Login”. Just select the Login and then type “.” that shows a list of objects available. Select WinEdit from the list.  Then again, open the bracket that shows list of available edit boxes. Select wdtAgentName and then again type “.”.  This shows list of methods available to be performed on this object. Select “Set” and provide the parameter admin inside the double quotes.

This procedure should be followed to the second and third lines also.  For the first time, this looks very tedious but after getting used to this, becomes very easy.




Repeat this process for other two lines also. I hope this explains well the process of creating a local object repository, adding objects, and using the same to create a test script.

We will discuss creation, addition of objects, and usage of Shared Object Repository in the next post.


  • Local / Per-Action OR is specific to a particular test / action.
  • Local Object Repository cannot be reused across all the tests in the automation suite.
  • This is the default object repository

Comments 8

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.