Can virtual objects be defined using Descriptive Programming and also can we get the properties of Virtual Objects?
Overview of Virtual Objects:
Virtual Objects are objects in the application which behave like Standard objects but cannot be recognized by QTP.
So using Virtual Object Manager, we can map this Virtual Object to a Standard Class(based on its behavior) and its boundaries and can assign to a standard object(Parent).
By using Virtual Objects, you need to make sure that the application window should be at the same position and same size when you record and run your tests.
So come back to our question, can we define virtual objects using descriptive programming?
Answer is "Yes"
But we need to define x,y,width and height properties to define the virtual object.
It looks like something below:
window("Paint").WinObject("NetUIHWND").virtualobject("x:=256","y:=66","width:=22","height:=20").highlight
window("Paint").WinObject("NetUIHWND").virtualobject("x:=256","y:=66","width:=22","height:=20").Click 13,11
But how can we get these coordinates?
In a new QTP Test, add the virtual object and just record an action in the virtual object.
Once you get those coordinates write a script like above.
You can also these is "v" label added to the virtual object(see the attachment).
2nd Question: Can we get the properties of those virtual objects?
Answer: Yes
If the virtual object is added to the Object Repository(OR), then you can use the GetTOProperty to retrieve whatever properties associated in the OR. You cannot get any values of the properties which are not in OR. So from the above screenshot, you can get only x, y, width, height and name property values only.