HP QTP is a automation tool used for functional testing. It helps in testing both web and windows based applications. The tool is developed using a platform dependent VBScript scripting language. QTP is also called advanced keyword driven testing tool. It was designed by Mercury and acquired by Hewlett Packard(HP) later.
QTP identifies the object present in our application mainly through two ways,
- Object Repository
- Descriptive Programming
Object Repository is the default way of object identification in QTP. Here the properties and values of every objects are stored in storage place of QTP i.e object repository. So while recording an application, all the objects you click/interact, will get stored to Object Repository. With the help of object repository during playback, QTP will identify the object on which the action is to be performed.
For storing object information, QTP has two types of object repositories
- Shared Object Repository
- Local Object Repository
1. Shared Object Repository:
It is one of the familiar and efficient ways to store the object information to the file which can be accessed by multiple test. The scenario is ideal when the object description changes frequently and the application is dynamic. Automation projects mainly use shared object repository and the filename extension used is .tsr.
2. Local Object Repository:
Local Object Repository stores object information with respect to specific actions in a file to care access right to stored objects via that action. The file name uses the extension .mtr. Local Object Repository is ideally used when the application is not dynamic.
Descriptive programming is used when an object is not stored in the object repository. So QTP will not search for object properties in object repository but will take from descriptive programming statement. Descriptive programming can be used in two ways.
In static method to a single line in the form of string arguments we directly provide set of properties and values.
Descriptive programming syntax in static method is as follows:
object's Class Name("property name:=property value")
In dynamic method we make use of Description object for writing descriptive programming. This is also known as Programmatic Description. It is used with child objects. Identification of an object will become more easy if we are using multiple properties. It becomes very useful if we are using index property for finding the object.
Descriptive programming syntax in Dynamic method is as follows:
Set MyDescription=Description.Create(); MyDescription(“property”).Value= “property-value”;
How descriptive programming is better than object repository:
- While using object repository you can come across maintenance and recognition issues and one solution to this is descriptive programming and hence we can ignore object repository.
- We also choose descriptive programming over object repository when objects are dynamic and we need to rely on special handling for identifying the same.
- When the object repository size increases and the performance of QTP is decreased when an object is recognized at the same time.
- Maintenance is easy using descriptive programming than object repository.
- In QTP while we are using descriptive programming , action can be performed on an object even if the object description is not present in object repository. But it is not the case with the object repository.
- Even if the application has not been developed we are able to create automation script using descriptive programming.
Object Repository alone cannot handle many special circumstances which can be done alone by descriptive programming. So descriptive programming can be considered as an alternative for object repository but cannot be treated as a replacement for object repository.