Tuesday, November 25, 2008

Object Repositories

Object Repositories in QTP 9 (QuickTest Professional)


An object as we know is a graphic user element in an application e.g. a button or a list or an edit box and the special characteristics of an object within the QuickTest are called object properties. QTP stores the recorded object properties in Object Repository.



Object Repositoriesare of two types Local and shared.

If objects are stored in a Local Object Repository then these are available to specific actions but not to all the actions. But if these objects are stored in one or more Shared Object Repositories then multiple actions or tests can use them.

By default QTP makes and uses Local Object Repository. If we create a new blank test and do a recording on it, QTP automatically creates a Local Object Repository for that test or action and stores the information about any object it finds in that corresponding Object Repository.

In QTP 9 we can associate multiple Shared Object Repositories with an action. If multiple Shared Object Repositories are associated with an action then also while recording QTP stores objects in corresponding Local Object Repository on the condition that those objects are not already stored in any corresponding associated Shared Object Repositories. This is the default that every time we create a new action QTP creates a new corresponding Local Object Repository. It is also true that Object Repositories are associated with actions and no matter how many times we learn or record on the same object in our application in different actions the object will be stored as separate test object in each of the Local Object Repository. Local Object Repository is automatically saved with the test when we save it. The extension of the Local Object Repository is .mtr, but it is not accessible as a separate file as in case of the Shared Object Repository.

We can also manipulate some aspects of Local Object Repository using Quick test Object Repository Automation Object Model. For example we can add, remove, rename test objects in Local Object Repository. (QuickTest Object Repository Automation documents the Object Repository automation object model that enables you to manipulate QuickTest object repositories and their contents from outside of QuickTest.)

When we open a test that was created using a version of QTP earlier that version 9 we are asked whether we want to convert it or view it in read only format. In any case if the test previously used per-action Object Repository, the objects in each per action repository are moved to the Local Object Repository of each action in the test.

If the test previously used a shared object repository, the same shared object repository is associated with each of the actions in the test, and the local object repository is empty.

While learning or recording we can specify Shared Object Repository for the selected action. We can specify and associate one or more Shared Object Repositories with each action. We can also create new Shared Object Repository and associate it with our action.

In case of Shared Object Repository, QTP uses existing information and does not add objects to the Object Repository if we record operations on an object that already exists either in Shared or Local Object Repository.

As said earlier QTP does not add objects directly to the associated Shared Object Repository as we record, instead it adds new objects in Local Object Repository (if that object does not already exist in associated Shared Object Repository).

We can surely export Local objects to Shared Object Repository.

There are different ways in which we can move objects from Local Object Repository to Shared Object Repository:

1) Exporting the objects to the Shared Object Repository from the Local Object Repository: In Object Repository window choose the action whose local objects you want to move. Choose File-> Export Local Objects.Select the location in which you want to save the file. Click on save.

2) We can update the Shared Object Repository with the Local Object Repository:

f we create a new test it will be created with Local Object Repository, we can associate any new or old Shared Object Repository with it, and so we can update that Shared Object Repository with Local Object Repository.

In Object Repository Manager open the Shared Object Repository (clear open in read only check box).

The test in this case should not be open. In Object Repository Manager go to Tools –> Update From Local Repository. Select the test who's Local Object Repository you want to use. Click update all. It will move all the objects to the Shared Object Repository.

3) We can also merge objects from two Object Repositories (called as primary and secondary in QTP 9) into a new single Object Repository (target Object Repository in QTP 9). The original source files are not changed. It also enables you to merge objects from Local Object Repository of one or more action(s) into a Shared Object Repository. It is recommended to use as a primary Object Repository the file in which you have invested alot of your effort, like which has more number of objects.

We can compare two Object Repositories using the Object Repository Comparison Tool. The tool enables you to identify similarities, variations or changes between two Object Repositories.

We can also copy objects to Local Object Repository from the Shared Object Repository. We can copy, paste and move objects in Local Object Repository and copy, paste and move objects within Shared Object Repository and between Shared Object Repositories.As said earlier we can also copy objects from shared Object Repository to Local Object Repository to modify them locally.

We cannot remove an association between the action and its Local Object Repository.

No comments: