How to Use Virtual object in UFT to Identify Non-Standard Class Objects

A virtual object in UFT is used to identify an object when UFT can’t recognize it using objects standard class.UFT doesn’t recognize an object if it is a custom or non-standard class object. If an application contains non-standard class objects, in that situation custom objects, can be mapped to standard class objects like buttons, checkboxes, etc to perform the required action.

Let’s try to understand this by automating the click operation on the ‘SAVE” button of MSPaint. If you use object spy to view its properties, UFT identifies the entire MSPaint upper bar as a single WinObject rather than identifying the “SAVE” icon as a single object.  

We will create a virtual object to treat the save icon as a button object. Go to the Tools> Virtual Object> New Virtual Object and click on the “Next” button.
 
Virtual Object UFT
We will map the SAVE object against the Class button and click “Next”.
Virtual Object UFT2
Click on the “Mark Object” Button and capture the width and height of the object and press the “Next” button.
Virtual Object UFT3
Select the parent object of the virtual object and click “Next”.
Paint Object UFT
Now you will have to give a valid name of the object. In our case, the name is “btnSave“.Click the “Finish” button.
Virtual Object UFT 5
Now, to use the virtual object, you have to start recording and click on the Save icon. The below code will be generated automatically.
Window(“Paint”).VirtualButton(“btnSave”).Click


Limitations of Virtual Object

  • UFT does not support virtual objects for analog or low-level recording mode.
  • Virtual objects can be added to the script only by recording action on it.
  • A checkpoint can be added to a Virtual Object.
  • Virtual Objects cannot be added by Object Repository.
  • A custom object can be mapped to a particular class like (button, checkbox, table, etc). However, all the methods of the native objects are not supported by Virtual objects.
  • The test execution will fail if the screen resolution changes.
  • The virtual object uses height and width properties which might change.

Recommended Posts

Leave a Reply