Virtual Object in UFT

When Nothing Works (as-in when UFT is not able to identify objects the usual way), Virtual Object in UFT (formerly QTP) is the weapon to achieve awesomeness of automation. Sometimes you find that UFT is not able to recognize an object, even if the object behaves like a standard object. Virtual object helps in such situation, enabling the object recognition and test execution.

Virtual object enables you to define objects as virtual objects and map them to standard classes such as button, text box etc. UFT /QTP emulates the actions on virtual object during the run session. A virtual object is defined using the virtual Object Wizard. The wizard prompts you to select the standard object class to which you want to map the virtual object. You then mark the boundaries of the virtual object using a crosshairs pointer. Next, you select a test object as the parent of the virtual object. Finally, you specify a name and a collection for the virtual object. A virtual object collection is a group of virtual objects that is stored in the Virtual Object Manager under a descriptive name. Virtual Object Manager feature enables us to create and manage virtual objects.

Virtual Object Wizard

Launch Virtual Object Wizard from UFT Menu Option : Tools > Virtual Objects > New Virtual Object 

Select Next at Welcome screen

Virtual Object Welcome Screen
In the next screen, Select the class which most resembles your virtual object. Basically we are mapping the object to standard class. The virtual object will be treated and behave like the standard class object you choose.

Virtual Object Select Class
Click on Mark object button and mark the area in application (around the object you want to create virtual)

Virtual Object Mark

Click Next to move to Object Configuration screen. Here you define how this object will be stored. You have two options to choose from

  • Entire Parent hierarchy – if you want to add the whole hierarchy in order to identify the object in one occurrence only i.e. within the hierarchy. UFT will not identify object if the hierarchy changes. For example, if the virtual object is defined using Browser(“A”).Page(“B”).Image(“C”), UFT does not recognize it if the hierarchy changes to Browser(“X”).Page(“B”).Image(“C”).
  • Parent only – if you want to add only the parent in order to identify object for all hierarchy. For example, if the virtual object was defined using Browser(“A”).Page(“B”).Image(“C”), UFT recognizes the virtual object even if the hierarchy changes to Browser(“X”).Page(“Y”).Image(“C”).
See also  Most Popular 40 Selenium Interview Questions With Answers

Virtual Object Configuration

Click Next to move to Save Virtual Object screen. You may want to name your virtual object. So that you can easily distinguish with other objects or in case you are creating multiple virtual objects. Specify the desired object name and the collection name and click Finish to Save your virtual object.
Virtual Object SaveIn case, you need to create another Virtual Object. you should select Yes for ” Do you want to define another virtual object?” The wizard will repeat again for your next virtual object.

Virtual Object Manager

Select Tools > Virtual Objects > Virtual Object Manager to open Virtual Object Manager. Virtual object manager list all of available virtual object collections. We can delete the virtual object from virtual object collections.

Virtual Object Manager

Enable/Disable Virtual Objects

To disable recognition of virtual objects while recording select Tools > Options > GUI Testing tab General node, and tick the “Disable recognition of virtual objects while recording” option.

Virtual Object Options

In the next post of Virtual Objects – The Descriptive way, you can find how to write descriptive statements with Virtual objects.


Tips

  • Object Spy does not work for virtual objects
  • You should not create Virtual Object for Scroll bars and Labels 
  • QTP does not support virtual objects for analog or low level recording.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.