What’s the Method QTP Uses for Unique Object Identification? – This constitutes the seventh installment in our QTP training series.
We’re currently preparing ourselves by understanding all the basic concepts needed to execute effective QTP tests. We’ve already discussed QTP’s Record and Run settings, Keyword view operation, and other related topics.
Recommended IPTV Service Providers
- IPTVGREAT – Rating 4.8/5 ( 600+ Reviews )
- IPTVRESALE – Rating 5/5 ( 200+ Reviews )
- IPTVGANG – Rating 4.7/5 ( 1200+ Reviews )
- IPTVUNLOCK – Rating 5/5 ( 65 Reviews )
- IPTVFOLLOW -Rating 5/5 ( 48 Reviews )
- IPTVTOPS – Rating 5/5 ( 43 Reviews )
=> Check Out The QTP Training Tutorials Series Here
This is the successive post in the series that discusses a pivotal aspect of QTP – The approach it adopts to distinguish an object uniquely.
The Unique Object Identification Method of QTP
Considering the screen image above, it consists of 3 buttons and 2 text boxes along with various other elements in this dialog.
In the prior examples, when we input the username and password, we saw how QTP documented the same actions in terms of programming code and a table in keyword view. Now, during playback, how does QTP recognize that the value we supply as Agent Name or Password has to be entered correspondingly in those edit boxes. Or how could one identify which button to press to submit the entered values?
Let’s endeavor to find the answer to these questions.
It’s evident that QTP remembers in some way which object to interact with. The way it does it is by storing the object in the AUT as a test object. It subsequently examines its properties and categorizes the object. For instance, when it comes across the OK button, it investigates its characteristics, and based on them, it designates the object as a “WinButton”.
QTP possesses a predefined collection of properties that it retains/learns for every object type it recognizes.
This involves three aspects:
- Mandatory properties: This refers to the property set for a certain class that QTP perpetually stores. One could consider this as the object description. It also corroborates this along with the parent object to discern if the description is ample enough to uniquely identify the object.
- Assistive properties: If the mandatory properties’ description is insufficient to identify the Object, a selection of optional properties will be appended to the description sequentially until there’s adequate information to identify the object.
- Ordinal Identifier:: If assistive properties also don’t result in a unique identification of an object, QTP appends a specific ordinal identifier, analogous to the object’s position on the page or in the source code.
This is the process by which QTP configures Test Objects. It uses this Test Object description to search for objects to interact with during a run session. It selects objects that match perfectly with the embedded description. These objects are referred to as Run-Time objects.
Unless your application undergoes substantial changes, the Test Object description that QTP holds will suffice to locate an object.
For the WinButton object present in our Flight app, let’s view the properties QTP has retained. This information can be accessed in the Object Repository. The menu option “Resources -> Object Repository” will open the OR for us. Alternatively, CTRL+R or clicking the icon are the other ways to do this.
If you observe in the image above, it retained the ‘text’ in the WinButton as its description to identify this button during runtime.
For more intricate applications, the tester can add or eliminate certain properties to devise a description robust enough to accurately identify the object at runtime. To do this, just click on the ‘+’ symbol.
All remaining properties of the object will be exhibited. The user can opt to incorporate one or more of these properties.
There’s also a feature called “Visual Relation Identifier” in the OR screen for the WinButton properties.
This feature facilitates object recognition in relation to their adjacent objects in the AUT. Once set, it forms a sort of link for the less stable components in your AUT with the objects that are more uniquely identifiable.
As long as these objects maintain their relative position to these unique objects, QTP will be able to recognize them. To establish this type of positional link, we are going to click on this column in the OR and the following screen will be displayed.
On this screen, select the ‘+’ icon to add an object with which you desire your test object to have a positional link.
I’ll choose “Agent Name” and specify that this object should be above the “OK” button.
So, Here’s How I Set it Up:
Now, if by chance some attributes of the OK button alter in the future, then QTP will still recognize it, provided the “Agent Name” is above it.
Intelligent Identification
This is the technique that QTP employs under one of these two circumstances.
The description that QTP has for an object:
- Doesn’t correspond with any runtime objects.
- Corresponds with multiple objects.
This is somewhat of a sophisticated concept, so we’ll delve into it at a later time through some examples for a more comprehensive and easy understanding.
Ordinal Identifier
This is a numeric value that represents the relative sequence of the object concerning objects that share the same description. If Object 1 and Object 2 possess the same mandatory and assistive properties, then the ordinal identifier will be employed to uniquely recognize the object.
This value is relative to the other objects on the screen, thus if any changes occur on the screen, then this identifier will not be useful.
It’s important to note that if the mandatory and assistive properties are sufficient, an ordinal identifier is not designated during recording. It can be appended later by clicking on the corresponding column for the object in the OR.
There are 3 Types of Ordinal Identifiers:
- Index: This is based on the sequence of the appearance of an object in the application code.
- Location: Depending on the position on the screen, dialog, or page.
- Creation Time: This applies only for browser objects. If 2 browsers with similar properties exist, then the one created first and the next one is considered.
For Instance, let’s comprehend how the ‘index’ identifier functions in our Flight application’s login screen:
These are the components:
As seen, the static text and the edit boxes share the same ‘text’ property.
If I know that one of them is static text and the other is a WinEdit object, then there’s no problem at all. However, if all of these are treated as WinObject then I would need to specify which object to interact with.
This is only going to happen when mandatory and assistive properties as well as smart identification have failed. So in order to inform QTP on how to distinguish them, I’m going to allocate an ‘Index’ ordinal identifier, which can be done from the OR.
I’ll set the Agent Title static text identifier as 0 and for the edit box, it will be set as 1.
This is how it looks:
If I need to access the static text, then I can do it as follows:
WinObject(“text:=Agent Name:”, index:=0) – This will refer to the static text
WinObject(“text:=Agent Name:”, index:=1) – This will refer to the Edit box
The same concept is applicable to the Location identifier as well, except that we will choose the location in the window to determine the numeric value that’s applicable to a specific object.
Setting Up Object Identification Properties:
The mandatory, assistive properties, and ordinal identifiers to be considered for an object of a certain class can be set up using “Tools -> Object Identifier”. We can also set up smart identification properties via this window.
Here’s What the Window Looks Like:
As observed in the image above, the environment can be selected from the drop-down box. Once that is selected, the object classes in the corresponding environments are displayed in the list. After an object is chosen, the mandatory and assistive properties are displayed. The user can Add/Remove additional properties to this list.
Moreover, smart identification can be turned on/off for a particular class of objects as needed. To set the ordinal identifier, there’s a drop-down that can be chosen to identify the object through Location, Index, or Creation Time (only for browser type).
Before proceeding with comprehensive QTP programs, we will touch upon the basic concepts first. The following QTP article will cover different recording modes, Object Spy, Object Repository, etc. in more detail.