Every test automation tool is GUI (graphical user interface)sensitive. Test automation tool has to identify the objects on the application, then only it can do the intended operations.
QuickTest Professional has its own mechanism to identify the objects on the Application Under Test. QTP has various add-ins available for different applications. Let us have a look at the QTP’s object identification mechanism.
- Open QTP
- Click Tools –> Object Identification
- Object Identification dialog gets opened.
In QTP 9.2 standard installation, it comes with ActiveX, Visual Basic, and Web add-ins and can identify the objects of ActiveX, Standard Windows, Visual Basic, and Web applications.
QTP identifies the objects with the following properties:
- Mandatory properties
- Assistive properties
- Smart identification
- Ordinal identifier
Will get into each one of these bullet points later. Let us have look at one of the important features of QTP which will be used many times during the test automation of an application is “Object Spy”.
Open the Application Under Test (AUT)
Click Tools –> Object Spy..
Click on the hand button on the spy
Click on a particular object on the AUTs user interface.
All the properties of the object will be displayed on this spy.
Below figures illustrate how object spy displays the object properties (Windows, Visual Basic, and Web application are taken as examples)
Below are some of the important properties of an object on a Standard Windows application:
- Class Name
- attached text
When we try to spy any object on a Standard Windows Application, QTP will identify them as below:
These are the objects which we come across in a standard windows application. There are some more objects such as WinCalendar, WinScrollBar, etc.
Below picture shows the object spy which is having the object’s properties & Values of an Visual Basic application.
Below are some of the important properties of an object on a Visual Basic application:
- Class Name
- Vbname path
Below are some of the objects on a Visual Basic application:
As we can see in this list, every object that is identified on a VB application starts with “Vb”.
In the above picture, I have spied an object on a web application. Below are some of the properties which are repetitively used in web application automation using QTP.
- Class Name
- html tag
While creating the test scripts we can use any one of them if the object property is unique or the combination of multiple properties if that becomes unique to identify the object.
When the objects are added to Object Repository of QTP, by default some of these properties will become Mandatory properties, some Assistive Properties. Before adding the objects to OR, we can change the settings in Object Identification and tell QTP the way we want to add the properties of the objects.
Below diagram depicts the default Mandatory Properties for WebButton:
With these default mandatory properties, if we try to add the WeButton object on AUT, in the object repository the object contains these three properties with the Smart Object Identification enabled as the “Enable Smart Identification” check box is selected.
QTP identifies the objects with Mandatory properties, if the object does not contain these properties then it will go ahead with the Assistive properties. If both are absent (not added to Object Repository as they are absent for a particular object) then it uses either smart object identification (if enabled) or Ordinal Identifiers (location or index of an object).
This post covers practically how the QTP identifies objects on Standard Windows, Visual Basic, and Web Applications; what are the different types of objects; and their some of the most used properties during Test Automation exercise.
Basically, what happens during test automation is we will add objects of the AUT to the object repository. During the execution of the automated test scripts, QTP will compare the Run time properties of the objects to the one added to the object repository and then continues with the actions to be performed on the AUT.