Print Page | Close Window

Understanding Object Repository in QTP

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=7394
Printed Date: 27Dec2024 at 10:18pm


Topic: Understanding Object Repository in QTP
Posted By: Mithi25
Subject: Understanding Object Repository in QTP
Date Posted: 30Nov2009 at 12:03am
Understanding Object Repository in QTP (Quick Test Professional)
In my previous post , I have given some brief introduction to Object Repository.

In this post, I would like to give some more details about Object Repository in QTP.

Object Repository is a centralized place for storing Properties of objects available in AUT (Application Under Test).

Why Centralized place? And, Why we should store the properties of objects available in AUT?

First, I will explain below things which will be helpful for understanding answers of above questions.

- All software applications and websites are getting developed using many different components or small units (e.g textbox control in vb, input tag in HTML, webbrowser contorl in .net) which can be called as Objects.

- Each object will be identified based on the object type. And also, each object will have its own properties (e.g name,title,caption,color,size) for helping to identify by each of them. And also, each object is having specified set of methods.

- Some of the properties can be changed during run-time. These are known as RO (Runtime object) properties. And some of them can not be changed. They are known as TO (Test Object) properties.

- You can use ObjectSpy available in QTP IDE to see the TO properties & methods and RO properties & methods of any object available in your application. (Make sure that required add-ins are available).



If you see TO and RO properties of many objects in different applications using ObjectSpy, you will be in a position to distinguish between TO and RO properties.

- Since TO properties are used for uniquely identifying any object, QTP will store only the TO properties of any object in the Object Repository.

- QTP will store TO properties of any object of AUT in Object repository as Name&Value pair. You can refer the below screenshot.



- The Objects stored in the Object repository(OR) are called asTest Objects. Actually it is just equivalent to the corresponding actual object in AUT.

- All the Test Objects that are stored in Object repository(OR) are arranged in a hierarchical structure. (e.g Browser->Page->webelement).

- QTP will store the TO properties of the Objects in many different ways.


    * One simple way is, while doing Recording the TO properties will be stored to the OR.

    * Second way is, TO properties can be stored by pointing the mouse cursor to required object in the AUT.

    * Another way is manually adding the TO properties of the objects to the OR.



- Note that QTP won't store all the TO properties of the objects to the Object Repository. Only few properties will be stored to the OR, based on the setting done in Object Identification window. Refer the below screenshot. It can be opened from QTP IDE (Tools->Object Identification).



-Sometimes, QTP will store some additional properties such as index, location which are known as ordinal identifiers. Actually these properties won't be available in the object of AUT. It will be created by QTP automatically to distinguish two objects which are having exactly same TO properties. (e.g Some forms in the web pages will be have two submit buttons, one at top and another at bottom. QTP can identify them only based on location or index).

-Note that even QTP is storing TO properties based on properties of object of AUT (i-e real object), there is no need for all the TO properties to be available in RO properties collection also. (ie) QTP can derive (i-e do some manipulation) to get some new TO properties from one or many RO properties.

-Script can get TO properties of Test Objects using methods such as getTOproperty and getTOproperties. Even, TO property of TestObject can be changed using setTOproperty. But anyway, it will be valid only till exiting the execution. After completing the execution it will resume the actual TO property stored in the OR.
During run-time we can get the property of the runtime object using getROproperty.

-Till this point we have seen about storing the Test Objects in Object Repository.
During Run mode, QTP will use these stored properties for comparing them with properties of actual objects of AUT to identify them.

- These Test objects can be represented in the script as ObjectType and Object name. (e.g Window("Mozilla Firefox").Activate).

- The object repository will support editing of properties of Test Object and new properties can also be added to them.

- The value for the properties of the Test Objects in OR need not be a constant. We can parametrize the values so that the TO property can be dynamically changed for each iteration of execution.

Now we can come to our Initial question. By storing properties in the centralized place, maintenance and updation of Test scripts can be easily done whenever there is a change in UI (User Interface) of the AUT.
Assume that Login screen is used in around 20 Test scripts. If the Page name of login screen in changed, we need not make any change in all these 20 Test scripts. Just changing the property of Test Object in OR is enough.

Clear understanding of Object Repository is essential if you are willing to use QTP extensively. Because we may face lot of difficulties/challenges while working with QTP. We should have clear knowledge in OR to face/solve them. Just Recording and Playback won't help much. And also, Test Automation framework can be done very effectively only when you are familiar with understanding/handling of Object Repository.


-------------
http://www.quick2sms.com - Send Unlimited FREE SMS to Any Mobile Anywhere in INDIA,
Click Here



Print Page | Close Window