Working with UFT’s Object Spy


Most important aspect of automating applications is the identification of objects. For object identification and understanding, UFT provides a very important tool called Object Spy. Probably this is the most used tool within UFT. Object spy provides us, important information about the object properties and operations.

Spying Objects using Object Spy

To open object spy, go to Tools->Object Spy. For checking object properties and operations, object spy has five buttons on the top.


Hand Pointer ()

To check the properties of any object click on the hand pointer and then click on the object. Object hierarchy and properties will be loaded in the object spy. Once Object type hierarchy is loaded within object spy, you can click on any of the object to check its corresponding properties.


Spying Google search textbox


Spying Link properties

Once you select and object within object hierarchy, other three buttons will be enabled.

Highlight in application(HighlightinApp)

Highlight in application button will highlight the select object in the application. This option will allow us to understand about the location and structure of the different objects within the application. This is an important feature, because sometimes while spying objects, we will not know about some hidden objects like web tables, which can be used effectively for writing scripts.

Add Objects to repository(AddObjectToRepository)

This button will instantly add the objects to the object repository; this will also create the object type hierarchy in the object repository. Once object is present in the object repository, object hierarchy window in the object spy will show () indicator below the object type image.

Copy properties to clipboard(Copytoclipboard)

This button will copy all of the object identification properties to the clipboard. It will be very useful for the analysis of the objects. Generally while writing complex objects, automation engineers will use descriptive programming instead of object repositories. For writing descriptive program we will need to know the properties of the object and changes in the behavior of the object at runtime. We will learn about the descriptive programming in the later posts and will discuss about this feature again there.

Keep Object Spy on Top (KeepOnTop)

This is self-explanatory. If you click on this button object spy window will be the topmost window during the identification of the objects.

Note: To perform mouse operations during object spying, press and hold Ctrl key

Object properties

Once you select the object using the hand pointer, object spy will load two different types of properties


Identification Properties

Identification properties are the set of properties used by UFT for the identification of the object. These are the only set of properties which can use with object repository. We can use any Single/combination of properties for the identification of the object during runtime. Identification properties can be accessed using “GetRoProperty” (Get runtime object property) function.

MsgBox Browser(“Browser”).Page(“Google”).WebEdit(“q”).GetROProperty(“text”)

Identification properties of the objects can be set during runtime using SetToProperty function.

Native properties

Native properties are the properties of the object assigned either by the developer during development or by the programming environment. Because native properties are programming environment depended, native properties for a Java textbox and a .Net based textbox might be different. Native properties can be accessed using .Object property

MsgBox Browser(“Browser”).Page(“Google”).WebEdit(“q”).Object.isMultiLine

Note: To assess native properties through intellisense, application must be open and the object must be loaded within the application. There might be multiple levels of native properties (e.g. Object.Items.Count), which can only be accessed through programming. Object spy will only show first level properties.


Object Operations

For each selected object, Operations which can be performed on that object will be listed here. There are two types of operations which can be performed on the objects.


Test object

UFT provides basic set of operations which can be performed for each object defined within UFT. More common operations like, click are available for each object. custom operations are also available for each type of object like “set” is available for textbook and “select” is available for combo box/weblist. There is a specific use of each operation. Details about the operation and usage can be seen by clicking on the operation name. Test object operations can be called directly on the object.


Like native properties, native operations are either custom operations developed by developers at runtime or the operations provided by the programming environment of the application. For calling the native operations on the objects we have to use the same approach, which we used for calling the native properties.


In the above example I have called the exit function on the browser object for closing the object.

How object spy works?

I am sure that every automation engineer who have ever created scripts in UFT can tell you that it’s the most wonderful tool available within UFT and object spy is so addictive that even when I was automating tests with selenium, I am using it for the identification of tests. It got me thinking about are there any other options for object spy.

With professional version of visual, a tool called spy++ is bundled and can be used for spying objects for windows based objects. I found couple of other tools capable of doing the same thing by simple google search.

Another wonderful functionality of object spy is that it can identify objects below mouse pointers, without this simplification I can’t think of any other simple and realistic way of object identification.

Now let’s talk about one another feature linked with object spying “add-ins”. Add-ins is another amazing feature available within UFT. You choose the add-in specific to the development environment of your application. But have you ever tried automating something without loading the correct add-in. I tried for browser and object spy instantly loaded windows instead of browser and page hierarchy.

Now let’s put all this information together to fully understand the object spy functionality.

Within windows operating system, we have a core set of API which can be used for changing almost anything within windows. It’s called win32 API. If we have to create a replica of visual studio’s spy++ we can simply use the functions available within this API.

The most important thing as an automation engineer is that, when I spy on browsers using spy++ it generates almost the same hierarchy, which is generated by UFT’s object spy. I said almost which means that UFT’s object spy is hiding some of the unnecessary objects in between.

Another important thing is how every object spy is able to find objects below mouse pointer, and answer to that is win32 API for windows based applications, which provides one function called “windowfrompoint” this function is inbuilt into window operating system and can give the objects reference which is below mouse pointer.

For Internet explorer we have a similar function available which provides the element details below the mouse pointer “elementFromPoint”, this function is inbuilt in IE and any one can use it to find the objects under mouse pointer.

So basically, object spy is a tool which leverages the API’s available within windows and different programming environment to generate the .object hierarchies.

We have also discussed about the add-ins, add-ins are available for automating different types of applications. When UFT creates an add-in, it simple creates a separate identification engine for the set of objects. So, if we load Java add-in, UFT will have a separate engine for the identification of the Java objects and then when you try to spy Java objects with object spy you will start receiving the Java specific hierarchy. But still if you load only Java add-in, you cannot spy on web browsers and object spy will show browsers as window object.

We can also use, two add-ins together, that means that these object identification engines can be used together for the identification of objects.

Now, when we have a basic understanding about the object spy we can discuss about loading multiple add-ins, within one UFT test. If we load multiple add-ins within one UFT test, UFT will have to go through each add-in for the identification of the object and it will be a time consuming and memory consuming task. So, it’s advisable to load minimum add-ins as possible and we can always create multiple tests and call them within each other to tests different types of applications. When you try to load multiple add-ins with UFT, it will through a warning message “For optimal performance and object identification reliability, select only the add-ins you need“.


We will discuss in detail about UFT/selenium less automation for windows and web based applications, later posts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s