QTP - Virtual Objects
What are Virtual Objects?
Sometimes, 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, In the Insert Ribbon, User clicks on "Picture" button. A Button is recognized as WinObject hence importance of vitural objects is pronounced.
Window("Microsoft Word").WinObject("Ribbon").Click 145,45 Window("Microsoft Word").WinObject("Ribbon").WinObject("Picture...").Click 170,104
Creating a Virtual Object
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 "Next" Button
Step 2 : Map the Object against the Class Type and click "Next".
Step 3 : Click "Mark Object" Button, cross hair cursor would appear and mark the object that you would like to map and click "Next".
Step 4 : Selecting the parent of the Virtual object and click "Next".
Step 5 : Name the collection in which you would like to store the vitual object and click "Finish".
Virtual object Manager
Virtual object Manager manages the collections of Virtual objects. Testers can add or Delete the Virtual Objects from the Vitual object manager.
Navigation to Virtual object Manager : "Tools" >> "Virtual Object Manager" as shown below:
Using Virtual Objects
After creating the Virtual Objects the created object can be used as shown below:
Virtual Object Limitations
QTP doesn't support virtual objects for analog or low-level recording.
Checkpoints cannot be added on Virtual Objects.
Virtual Object 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.