Object Identification
QTP performs the operation only after identifying the object uniquely. In order to identify the object uniquely it uses property values of the respective object which will be stored in the Object Repository.
Note: To view the property values of the object, QTP uses Object Spy. Object Spy is a tool available in QTP.
Each object has many property values, storing all the property values of the values of the object not only consume more space and also reduces the performance of QTP. In order to solve this QTP stores minimum property values based on the Object Identification settings. Object Identification has following sections:
- Mandatory Properties
- Assistive Properties
- Ordinal Identifiers
Mandatory Properties: During recording first QTP goes to the Mandatory Property section of the respective object type and reads all the mandatory property values of the object from the application if they are sufficient then it will be stored in the object repository or else QTP will go the assistive properties.
Assistive Properties: QTP reads the assistive property (non mandatory) values one by one, if it is sufficient then the values will be stored in the Object Repository or else QTP will go to Ordinal Identifiers.
Ordinal Identifier: QTP goes to Ordinal Identifier only if the Mandatory and the Assistive property values are not sufficient. Ordinal Identifiers are classified into three types
- Location
- Index
- Creation Time
Location: It is the sequential number (0, 1, 2….) etc. generated by QTP based on the order in which object appears on the application. QTP starts the scanning process from LEFT top corner of the application and it will scan every column from left to right. In this scanning process the first Objects gets the location value 0 then the next object will get the location value 1 and so on.
Example:
The value of location for the group of text boxes will be as follows:
Note: Location value for objects is generated only for the objects that are having the same Mandatory and Assistive property values.
Index: It is the sequential number generated by QTP based on which the object appears in the source code.
For the same example the value of index for the group of text boxes will be as follows.
Creation Time: It is the sequential number generated by QTP based on the time the when the browser was launched. This means that the browser that is launched first will get the creation time as 0 and the second browser that is launched will get the creation time as 1.The third browser will have a creation time of 2 and so on.
Example:
SystemUtil.Run "iexplore.exe", "http:// www.gmail.com" //this will get CreationTime 0
SystemUtil.Run "iexplore.exe", "http:// www.ksrtc.com" //This will get CreationTime 1
SystemUtil.Run "iexplore.exe", "http:// www.irctc.co.in" //This will get CreationTime 2
Object Repository
It is a storage place which is used for storing the objects and its properties and it also acts an interface between the script and the application under test (AUT) to identify the objects during execution of the script.
Types of Object Repository:
- Local Object Repository
- Shared Object Repository
Local Object Repository: Every action has its own object repository called as Local Object Repository. The objects present in Local Object Repository can be accessible only by respective actions and cannot be accessed by other actions. Local Object Repository (LOR) stores property values of an object in a file with the extension (.mtr).
Shared Object Repository: It is the centralized object repository which can be accessible by multiple actions. To overcome the drawback of LOR, SOR’s are being used. Shared Object Repository (SOR) stores property values of an object in a file with the extension (.tsr) which can be accessible for multiple tests.
Note: To use Shared Object Repository user has to associate the .tsr file to the test
Difference between Local Object Repository and Shared Object Repository
Local Object Repository |
Shared Object Repository |
1.Object present in the Local Object Repository is accessible only by respective action |
1. Objects present in the Shared Object Repository can be accessible by multiple actions. |
2.By default actions always contain Local Object Repository |
2.Shared Object Repository ‘s has to be created separately and then it has to be associated to the actions |
3.Name of the Local Object Repository is always Object Repository |
3. Name of the SOR is user defined. |
4.By recording we can add the objects in the Local Object Repository |
4.By recording objects cannot be added to the Shared Object Repository |
5.Local Object Repository to Shared Object Repository is possible |
5.Shared Object Repository to Local Object Repository is not possible |
6.We cannot navigate and learn objects |
6. We can navigate and learn. (Means objects can be added in object repository by Navigating and Learning) this can be achieved with the tool available in QTP. |