Sometimes, an application under test may contain standard window object but are not recognized by QTP. Under these circumstances, objects can be defined as virtual object(VO) of type button, link etc. so that user actions can be simulated on the virtual objects during execution.
Let us say we are automating a scenario in Microsoft Word. I activated MS word application and I click on any icon in the ribbon. For example, on the Ribbon, Insert tab is clicked and then the user clicks the "Picture" button. A button is recognized as WinObject; hence, importance of virtual objects is pronounced.
Window("Microsoft Word").WinObject("Ribbon").Click 145,45 Window("Microsoft Word").WinObject("Ribbon").WinObject("Picture...").Click 170,104
Step 1 − In such scenarios, virtual Objects are created using Virtual Object Manager or New Virtual Object from "Tools" >> "Virtual Object" >> "New Virtual Object" and click the "Next" button.
Step 2 − Map the Object against the Class Type and click "Next".
Step 3 − Click "Mark Object" Button. A cross hair cursor would appear and mark the object that you would like to map and click "Next".
Step 4 − Select the parent of the Virtual object and click "Next".
Step 5 − Name the collection in which you would like to store the virtual object and click "Finish".
Virtual object Manager manages the collections of Virtual objects. Testers can add or Delete the Virtual Objects from the Virtual Object manager.
Navigation to Virtual object Manager : "Tools" >> "Virtual Object Manager" as shown below −
After creating the Virtual Objects, the created object can be used as shown below −
QTP does not support virtual objects for analog or low-level recording.
Checkpoints cannot be added on Virtual Objects.
Virtual Objects are not controlled by Object Repository.
Though we map an object to a particular class (button or List), all the methods of the native objects are not supported by Virtual objects.
Object Spy cannot be used on Virtual Object.
The test execution will fail if the screen resolution changes as the co-ordinates change.
Application Window should be of same screen size so that Virtual objects are captured correctly.