Virtual Objects – the Descriptive way

1
269
Virtual Objects

If you have used Virtual Object in UFT and that too using in recording mode. You are wondering, if we can use descriptive programming for virtual objects as well! The answer is — definitely a “YES”. UFT does have and you can easily do the same for Virtual Objects (referred as VO in this post). For those who are not aware of what Virtual Objects are, let us first understand what it is and how it works. VO feature in UFT enables us to create and run tests on objects that are not normally recognized by UFT. These objects can be any object that behave like standard objects but are not recognized by UFT. Virtual objects helps a lot in such situations. Read mode about VO in our previous post.

Virtual Object in UFT / QTP – When Nothing works

Recently, I encountered a situation where I had to click on a link. The link was in the email body. Although the link was behaving properly, it was not getting recognized by UFT, actually UFT was identifying the whole body section as an object. The Objective was to open the URL which was associated with the link. The URL opens only after clicking the link at the email body. I tried other means but no luck. Finally, in this situation VO was very helpful and it worked like a charm.

You can define such objects as virtual objects and map them to standard classes like button, checkbox etc. UFT emulates the actions on VO during the run session. A VO 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 VO. Finally, you specify a name and a collection for the VO. A virtual object collection is a group of VOs that is stored in the Virtual Object Manager under a descriptive name.

The Descriptive Way

The VO that you create using the virtual object wizard, gets stored as VOT file into <UFT installation folder>\ dat \ VoTemplate. Which means, if you want to use the script in with VO on another machine, you need to copy this VOT file to the same location on the machines. This is the 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 VO 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 VO collection or the VOT files on the machine. We can do the same with using description object as well.

 
  • Descriptive programming for VO 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”

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.