Search This Blog

Wednesday, January 5, 2011

Object Repositories in QTP


Object repository is a place where all objects are stored.QTP uses 2 types of object repository

  1. Per Action (Local)
  2. Shared
Per Action Repository:  By default qtp makes & uses Per Action repository .When qtp learned any object it create a local repository (for new test) within that test or action & stores description of the object in corresponding Action’s local repository automatically.
Objects stored in Per Action Repository will be available to corresponding actions only other actions can not access these objects. If you modify an object in the local object repository, your changes do not have any effect on any other action or any other test

When working with local object repositories:

  • QTP creates new object repositories for each action.
  • When QTP learns new objects it automatically add description of the objects in local object repository of corresponding action.QTP adds all new objects to local object repository even though one or multiple shared object repositories associated to that action.
  •  If a child object are added to local object repository & its parent is in associated shared object repository, its parent automatically moved to local object repository.
  •  Every time you create a new action its corresponding local object repository created automatically & as you learn object in you application these object are stored in local repository.
  • If QTP stores same object with in two different actions, its stores the object as separate object in both repository.
  • When you save your test local object repository save automatically.

Shared Object Repository: Objects are stored in one or multiple shared repository & other actions can also use them. By storing objects in shared object repositories and associating these repositories with your actions, you enable multiple actions to use the objects. For each action, you can use a combination of objects from your local and shared object repositories, according to your needs. You can also transfer local objects to a shared object repository, if required. This reduces maintenance and enhances the reusability of your tests because it enables you to maintain the objects in a single, shared location instead of multiple locations.

For the ease of use & access it’s always advised to use Shared Object repository as you can use same object repository for multiple actions if the actions include same object.
As all objects are stored at one central location at any point of time if object in application change you can update them in all the associated actions that used shared repository.

If the object with same name exists in both PerAction as well as shared repository for an action that action uses Per Action Repository.

When we open a test that was created in an earlier version of qtp a message displays that if you want to convert your test or view it as Read-Only. If the test previously using Per Action Repository the object of each Per Action Repository is transferred to the local object repository of each action.

If Object of previous test was using shared repository the same object repository is associated with each of the actions in the test & local object repository remains empty.

When working with a Shared Object Repository:

  • If QTP learns an object which is already existed in either shared or local object repository associated with that action it uses existing information & does not add that object to repository.
  •  If a child object are added to local object repository & its parent is in associated shared object repository, its parent automatically moved to local object repository.
  • When QTP learns a new object it adds to this object to corresponding action’s local object repository. You can export object from local object repository to shared object repository or you can export the entire local object repository & replace it with shared object repository & your local object now will be accessible to other actions as well. You can also merge objects from the local object repository to a shared object repository that is associated with the same action.


Ref : QTP Help

1 comment:

  1. Creates and returns a reference to an Automation object
    syntax: CreateObject(servername.typename [, location])
    Arguments
    servername:Required. The name of the application providing the object.

    typename : Required. The type or class of the object to create.
    location : Optional. The name of the network server where the object is to be created.

    ReplyDelete