Monday, October 3, 2011

Object and Object Repositories

Object and Object Repositories

Objects:

        In QTP all the elements are saved in script as objects. Objects are combination of properties which are unique in Nature. Objects are composed of types and properties. Each object will have its set of properties to identify its object uniquely in the Application. For example, for a  text box its type is text box and property is to write any text in it. At the time of execution , QTP identifies the objects on the screen by comparing them with the objects and their properties in the Repository.


Mostly used objects in QTP(I will be discussing based on Web application only)
Browser
Page
Links
List Box
Radio Button
Web Table
Frame
Image

Web Edit
and so on..

There are two types of object in QTP:

1. Test Objects
    Object stored in object repository are called Test objects.
2. Run Time Objects
    Objects which are identified in run time (i.e Dynamic)are called Run Time Objects.




Object Spy:


Object spy is used to know the object information which are properties and values of the object, the methods associated to it and Object Spy will also display the object's hierarchy(i.e Structured view of objects). We can get the properties and methods by selecting the object required by the Pointer in Object spy. We can use Object spy for both Run Time and Test Objects.

Note: In earlier versions of QTP we can only view the objects information from Object spy, From QTP 11 we can add objects to the OR directly from object Spy.




Object Repositories (OR):

Collection of objects pertaining to the application under test(AUT) are called Object Repositories.

Types of Object Repository
In QTP there are two types of object Repository and they are
    - Per Action object repository(Local Object Repository)
    - Shared Object Repository

Per Action Object Repository:

Which is also called as local object repository. This is the default Repository of QTP and saved within the action itself.This Object Repository Specific to actions (Will be used only for a particular action). This OR is preferable when application is not dynamic with respect to time. Per Action Object Repository cannot be reused.
 
File Type:
Per Action Repository's extension is .bdb

Shared Object Repository:

The collection of Objects which are stored in a file (with extension of.tsr) that can be accessed by multiple users at the same time,
is known as Shared object repository. By Default ,Shared Object Repository is opened in Read-only mode. To enable editing click File (QTP Toolbar) > Enable Editing Shared object repository occupies less memory than the local object repository.
 
File Type:
Shared Object Repository's extension is .tsr

How to make a Object Repository as Shared OR ?

To make an object Repository as Shared Object Repository open the Object Repository i.e
Resources --> Object Repository
Then go to File in the Object Repository and then Export Local Object
i.e File -->Export Local Objects
After that save the repository where you want to maintain the file with extension '.tsr'


Check out for Object Identification here