Virtual Objects – the Descriptive way

0
37

If you have used virtual objects and that too only after doing a record, and you are wondering if we have descriptive programming for virtual objects as well! The answer to these is –Yes, we do have and we can easily do the same for Virtual Objects. For those who are not aware of what Virtual Objects are, let us first understand what it is and how it works. Virtual object feature in QTP enables us to create and run tests on objects that are not normally recognized by QTP. These objects can be any object that behave like standard objects but are not recognized by QTP. Virtual objects helps a lot in such situations.

Recently, I encountered a similar situation where I had to click on a link which was there in the email body (I will elaborate the whole scenario in a seperate post). Although the link was behaving properly it was not getting recognized by QTP, actually QTP was identifying the whole body section as an object. objective was to open the url which was associated with the link and that was getting opened only after clicking the link at the email body. I tried other means but no luck. So finally in this situation Virtual Object was very helpful and it worked like a charm.
So, we can define such objects as virtual objects and map them to standard classes like button, checkbox etc. QuickTest emulates the actions on virtual object during the run session. A virtual object can be defined using the virtual Object Wizard(Tools>Virtual Objects>New Virtual Object).  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 cross-hair 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. Find more details on virtual objects step by step with screenshots in my earlier post ‘Virtual Objects – When Nothing works.’

The virtual objects that you create using the virtual object wizard, gets stored as VOT file into  <QuickTest installation folder>\ dat \ VoTemplate. That means, if you want to use the script in which you have added the virtual object onto some other machine then this VOT file also needs to be copied to the same location on the other machines wherever you want the script to execute. This is main challenge for maintaining the script and the execution on multiple machines or in other terms ‘portability’. To overcome this issue, Descriptive programming is the best way. Basically a virtual object stores and uses the properties x,y,width and height with it. so if by any means we are able to maintain these properties and values then we are done. below is an example of how we can do it

This way we can run the script without having the virtual object collection or the VOT files on the machine.We can do the same with using description object as well.

 
  • Descriptive programming for virtual objects can be done only for the classes which can be created using the virtual object manager.
  •  for virtual lists objects use one more property ‘rows:=row number”
  •  for tables use “rows:=row number” and ‘columns:=column number”

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.