Anyone who is familiar with object oriented language like java, would know about these terms. But does UFT has these objects, methods, classes and properties ?
The answer is ‘YES’ it does have all these. In this post we will know about object, methods, classes, properties, How to identify object properties in UFT/QTP. This post might look lengthy, but it was required to help you understand better.
Objects and Classes :
Today’s generation is all about internet of things known as objects. Objects are everywhere, anything which is visible can be considered as object for e.g, pen, dog, pictures, mobile phones (as in the above image), gadgets etc.
In the above image we have three objects :
- Samsung galaxy
- Microsoft lumia
- Apple iPhone
All of these are objects of class ‘Mobile phones’. Objects are instance of class objects.
Methods and Properties :
Any action that can be carried out on a object is called as ‘method’. In this case switching on and off, unlocking and locking the phone, answering the call are methods or actions performed on various mobile phones.
‘Properties‘ are the one’s required to identify the objects uniquely. In this example the size, color, OS of the phone, hardware specifications etc, are the properties which are same or different for the phones. To simply say, the specs of the phones are the properties.
The methods may be same but the properties of the phones are different although they are of the same class called ‘Mobile Phones’.
In UFT/QTP :
In UFT, All the GUI elements are considered as objects, like Buttons, Edit boxes, links, image, List box etc. The properties related to these objects are Text, Size, Height, width, Id and so on. Then comes the methods ‘Click’ on button, ‘set’ data in edit box etc.
To be more clear, have a closer look at the above image of a windows application :
- Edit box 1 and 2 are objects of class ‘WINEDIT’. Although, the objects are of same class, the properties are different. The name property of respective edit boxes are ‘Agent Name’, and ‘Password’ are different.
- Methods would be same ‘Set’ Agent Name as ‘xxxx’ and ‘Set’ Password as ‘*****’.
Similarly, for the ‘WINBUTTON’, which is the class and has objects ‘Ok’, ‘Cancel’, and ‘Help’. The method that is applicable to all the three is ‘Click’. It is not necessary that all the objects have same class, can be multiples as well.
If it is for ‘WEB Application’, then the classes would be:
now, by refering one of my previous posts about ‘VB Script’ look up , you will understand the concept even better.
So, a quick question comes up.
Q- How do you identify the properties of the objects ? A- Using Object Spy 🙂
The name itself indicates that, it is used to spy on objects i.e, to identify the object properties of an application. It is listed under menu Tools >> Object spy.
In the image above, the object spy is displaying the properties of the object ‘Agent Name’ which is the part of Login dialogue box. It also has the ‘Class Name’ listed as ‘WinEdit’. Other properties such as height, text ,enabled, etc are also available.
The order would be — Login dialoguebox >> Agent name edit box >> then set some data. similar order is applicable for the button also with .click method.
Dialog(Login).WinEdit(Agent Name:).Set XXXX Dialog(Login).WinEdit(Password:).Set **** Dialog(Login).WinButton(OK).Click
The video below shows you how to use the object spy tool in UFT.
With this, we come to the end of the post. Hope, you have understood about the most important terms and their usage. Thank you.
Note:UFT has sample applications available under start/programs/HP software/ Sample applications/ flight GUI