Virtual Objects
It enables to record and run tests on Objects that are not normally recognized by Quick tests.
For Example: If we try to record activities in a Chess Game,
Windows ("Chess"). activate
Windows ("Chess). click 82, 65
Windows ("Chess). click 17, 25
Windows ("Chess). click 34, 55
Windows ("Chess). click 74, 28
Windows ("Chess). click 82, 45
From the above code, we will never know what is 82,65 or 17,25.... To make clarity of steps, we can use Virtual Objects.
How to create a Virtual Object
- Tools> Virtual Objects> Virtual Object manager
- (Virtual Object Manager Wizard opens)
- New> Map to a standard class
- Choose: object/ Button/ Table/ List/ Checkbox/ Radio Button
- In our case, suppose there is a button on Chess Board as 'New Game' to start new game. and another button as 'Withdraw' to Withdraw from game. For that we will choose 'Button' and click on 'Mark Object'.
- A Cross-hair Pointer will appear to record Object. It's Width and Height is recognized as 82,45. Rename this Button as 'New'.
- Now, you will see the message:" Do you want to create another virtual object?' Yes/No
- Similar grounds, create another virtual object as 'Withdraw'.
- Now, There are 64 Boxes 8 Rows and 8 Columns. It is difficult to create 64 Buttons. rather, we can create one Virtual Object as 'Table'. Here, We will choose 'Table' and Mark the entire table with Cross-Hair Pointer.
In our example, Available Virtual Objects are:
VoCollection()
|_________ New
|_________ Table
|_________ Withdraw
Now, If we will start recording, our script will look like:
Windows ("Chess"). activate
Windows ("Chess). VirtualButton ("New"). click
Windows ("Chess). VirtualTable ("Table"). SelectCell 1,1
Windows ("Chess). VirtualTable ("Table"). SelectCell 4,4
Windows ("Chess). VirtualTable ("Table"). SelectCell 8,2
Windows ("Chess). VirtualButton ("Withdraw"). click
By using, Virtual Object, Code is easy t understand.
Please Note:
- Object Spy can't be used here.
- QTP supports Virtual Object only in Normal Recording.
- Virtual Objects Created are stored as .vot fileat the location:
<QuickTestInstallation folder>\dat\VoTemplate
No comments:
Post a Comment