How to add objects to the object repository (QTP 9.0)?

Adding objects to a local object repository:
An object can be added to the local object repository in one of the following ways:

1. Record some actions on the object; this will automatically add this object to the object repository. If you do not need the recorded statements in your script, you can delete them and it will not remove the added object from the object repository.

2. Add objects manually.

  1. Go to Resources -> Object Repository.
  2. In the Filter combobox, select “Local Objects.”
  3. Go to Object -> Add Objects to Local.
  4. Click on the object to be added to the repository.
  5. If the Object Selection window appears, select the desired object, and click <OK>.
  6. If the Add Object to Object Repository window appears, select the appropriate option:

    To add only the selected object, select the “Only the selected object” radio button. To add the selected object and its child objects of a specified type, select the “Selected object and its descendants of type” radio button. Then, select the checkbox next to the child object types that should be added.

  7. Click <OK>.

3. Manually define a new test object.

  1. Go to Resources -> Object Repository.
  2. In the Filter combobox, select “Local Objects.”
  3. Go to Object -> Define New Test Object.
  4. Select the appropriate Environment for your test object. For example, to add a Link object, select “Web.”
  5. Select the desired test object class for the new object.
  6. Enter a name for your test object.
  7. Fill in the Test object details as needed. The Test object details area automatically contains the mandatory properties defined for the object class in the Object Identification dialog box. You can add or remove properties as required, and define values for the properties.

    To add properties, click the “Add description properties” button (with the + icon). Select the properties to be added and click <OK>.
    To remove properties, select the properties to be removed, and click the “Remove selected description properties” button (with the X icon)

  8. Click <Add> to add the new object.
  9. Repeat steps d through h as needed.
  10. When done, click <Close>.

Note:
When you manually define an object, QuickTest Professional will not automatically add the object’s parent. If the parent objects are not present, you will need to define them as well. Once the objects are added to the repository, you can drag-and-drop them to their appropriate positions.

4. Add the object using the Active Screen.

  1. In the Active Screen, right-click on the object to be added.
  2. Select “View/Add Object.”
  3. If the Object Selection window appears, verify the desired object is selected, and click <OK>.
  4. In the Object Properties window, click <Add to Repository>.

Adding objects to a shared object repository:
An object can be added to a shared object repository in one of the following ways:

1. From a local repository.
2. Add objects manually.

  1. Go to Resources -> Object Repository Manager.
  2. Go to File -> Open -> <repository to open>.
  3. By default the repository will open in read-only mode. Go to File -> Enable Editing.
  4. Go to Object -> Add Objects.
  5. Click on the object to be added to the repository.
  6. If the Object Selection window appears, select the desired object, and click <OK>.
  7. If the Add Object to Object Repository window appears, select the appropriate option:

    To add only the selected object, select the “Only the selected object” radio button. To add the selected object and its child objects of a specified type, select the “Selected object and its descendants of type” radio button. Then, select the checkbox next to the child object types that should be added.

  8. Click <OK>.

3. Manually define a new test object.

  1. Go to Resources -> Object Repository Manager.
  2. Go to File -> Open -> <repository to open>.
  3. By default the repository will open in read-only mode. Go to File -> Enable Editing.
  4. Go to Object -> Define New Test Object.
  5. Select the appropriate Environment for your test object. For example, to add a Link object, select “Web.”
  6. Select the desired test object class for the new object.
  7. Enter a name for your test object.
  8. Fill in the Test object details as needed. The Test object details area automatically contains the mandatory properties defined for the object class in the Object Identification dialog box. You can add or remove properties as required, and define values for the properties.

    To add properties, click the “Add description properties” button (with the + icon). Select the properties to be added and click <OK>.
    To remove properties, select the properties to be removed and click the “Remove selected description properties” button (with the X icon)

  9. Click <Add> to add the new object.
  10. Repeat steps d through h as needed.
  11. When done, click <Close>.

Note:
When you manually define an object, QuickTest Professional will not automatically add the object’s parent. If the parent objects are not present, you will need to define them as well. Once the objects are added to the repository, you can drag and drop them to their appropriate positions.

4. Merge with another shared object repository.  

3 Responses to “How to add objects to the object repository (QTP 9.0)?”

  1. ash Says:

    Hi Amit,

    I have a problem related to object identification. Please take a look at this, and let me know if you can help with this:
    Hi Ankur/fellow testers,

    I am currently trying to run QTP scripts which were recorded on a PC- PC1, on one of my PCs- PC2 and the script continually fails at points where it does not find objects in the repository. I am forced to re-record time and again to solve this problem.
    Right now, I am doing this step where I’m logged into Outlook and am trying to select File –> Open.
    I get the following error for the Context Menu object

    The “ContextMenu” object was not found in the Object Repository.
    Check the Object Repository to confirm that the object exists or to find the correct name for the object.
    Line (36): “Window(“Outlook Express”).WinObject(“Outlook Express Message_2”).WinMenu(“ContextMenu”).Select “Open Ctrl+O””.

    How do we avoid this problem while porting between PCs? One of the approaches I tried was to export the objects in PC1 and save it as a .tsr file which i copied into the other pc, PC2. In PC2, I tried to import this tsr file by pasting the following bit of code in my qtp script:
    Dim App ‘As Application
    Set App = CreateObject(“QuickTest.Application”)
    App.Test.Settings.Resources.ObjectRepositoryPath =”c:\act.tsr”
    However, this failed with the error:
    You cannot change the object repository type for this test.
    Line (3): “App.Test.Settings.Resources.ObjectRepositoryPath =”c:\act.tsr””.

    Any idea? We are wasting a lot of time having to re-record/add objects which are not recognized.
    Appreciate any help.
    Thanks so much.
    ash

  2. samrat Says:

    my problem is that how can i check the combo box.suppose their are two Fields are their “india” and “USA” in combo box .want to check with qtp by right function .

  3. Prakash Says:

    Hi,

    This is Prakash. Am a novice in Automation. So to make myself familiar I downloaded the trail version of QTP 9.5 and installed in my notebook with Windows Vista. After normal installation, I was running “Additional Installation Requirements–>Configure DCOM settings”, I got this message “Run time error ‘424’: Object Required”. I clicked OK from the displayed window and finally it displayed that installation is completed.
    Then I started QuickTest Professional–>New Test..I noticed two issues:
    Issue 1: RECORD button is in disabled state.
    Issue 2: The default view selected is ExpertView and when I tried to select “Keyword View”. I can view ERROR(glowing in RED) at the bottommost right corner and also info “Syntax Error.See Information pane for details”.But nothing is displayed in Information pane.

    Already another faced the same problem and requested for solution in this blog.
    Can anyone assist me plz.
    my email is cmjayaprakash@gmail.com

    Thanks,
    Prakash

Leave a comment