Sunday 8 January 2012

Object Repository in QTP

Wooah!!! Let get into deep understanding of Object Repository (OR in Short)

As the name suggest "A place where Object is stored", but don't get confused. Object in QTP world is basically "PropertyName-PropertyValue" pair. QTP Object Repository is a Graphical representation Various Test Objects and their properties along with hierarchical relationship with other objects as well.

Their are some more functionality available in Object Repository window like . . .
 Add Objects to Repository
 Object Spy
 Associate Other Repository from file
 Highlight Selected Test Object in Application

These are very few enlisted above with Icon Image.

Now lets see how does an Object Repository GUI window looks like.

Left Pane shows the total Test Objects what is going be used by QTP during Test Run. Now these object can be added manually or by QTP itself while recording a script rather I should say a workflow.
Two thing keep in mind to get familiarize with OR.
1) Notice the hierarchical relationships among objects. People who can understand HTML DOM (Document Object Model) can easily figure out why these objects are placed in such order.
2) Notice the Icon and Name of each Object.

Right Pane shows an Object properties and its values.

Lets take an example of our Test Object having Name "Google Search"
Notice the Icon, its a WebButton and the name "Google Search" 
Look at the Right Pane now 3 Description properties are displayed like type, name and html tag.
QTP have itself added these 3 properties to uniquely identify a particular object in application.

Now you will ask me what do you mean "QTP has itself added these properties"? (Note that I am talking about object properties and not Object because I have manually added all those objects in OR, but QTP have itself added all the required properties of each object.)

When I click on Icon         QTP vanishes and Object Spy Hand  appears and placed on the object (Google Search Button) then QTP fetch all the available object properties from the application and using Object Identification Mechanism it filters out that it require above 3 properties to uniquely identify Google Search Button in Google landing page. 

QTP self assign a name ("Google Search") to Google Search button object so that automation tester can use this name as reference in his code.
Now let's around with this object, 
1. Click on highlight button  and then Google Search Button gets highlight
2. Delete  some property and see that whether you can identify (or highlight) object, I deleted property "html tag" and guess what I was able to highlight Google Search Button. And I again deleted property "type" and I was able to highlight Google Search Button. And I again deleted property "name" and guess what QTP showed me 

What did I concluded here.
QTP sometimes take extra precaution to uniquely identify object hence add some more properties without which it can still identify object uniquely.
I have learned that the more number of properties you add, QTP will take more time to analyze object. Hence I started deleting properties.

Okay pals try yourself . . .
Happy Learning . . . :)

-Pankaj Dhapola



No comments: