Saturday, June 4, 2011

General Run Error on using Browser.Back

I got a question from one of my esteemed reader which I am posting below:

Issue:
I am trying to use 'Browser("Browser").Back' but I always General Run Error. I am using QTP 9.5 and IE7. I have tried uninstalling/reinstalling QTP but the issue is still not fixed. It also seems to fail when I try Browser methods (I have also tried Browser("Browser").Refresh and it came up with the same error).

Possible Solution:

1. In IE settings, go to Tools -> Manage Add-ons
2. Select the BHOManager Class
3. Click the Enable button

If the above solution doesnt work, you can also try the below code:

Set oWshShell = CreateObject("WScript.Shell")
oWshShell .SendKeys "{BS}"

QTP Tip | Check Status of WebEdit

The following QTP code will check if a textbox is enabled or not

If Not oWebEdit.Object.Disabled Then
Msgbox "Object is Enabled"
Else
Msgbox "Object is Disabled
End If

QTP Mercury DeviceReplay vs SendKeys

Mercury DeviceReplay is a powerful utility to simulate keyboard input and also for simulating mouse clicks and movements. Under Java Add-in, you can find the DeviceReplay property. At times, Object.Set and Object.Type doesnt help in QTP for some applications. You can use Mercury DeviceReplay to type Non English symbols and letters even without changing the keyboard layout or installing the special fonts.

In Order to use the DeviceReplay methods, you need to create DeviceReplay object.

Set objDeviceReplay = CreateObject("Mercury.DeviceReplay")

We use SendKeys method to send keyboard input/keystrokes to applications that dont have automation interface. We can also send more than one keystroke at a time using Sendkeys method. To send keystrokes x,y and z, you would send the string argument "xyz".

Note: You cannot send Print Screen key to an application.

So, the difference between Mercury DeviceReplay and Sendkeys is

SendKeys -> Support only Keyboard Operations
DeviceReplay-> Support Keyboard + Mouse Operations like Drag Drop too.

In addition to that DeviceReplay supports sending multilingual characters and symbols, while sendkeys support limited keyboard operations.

The other operational difference is dependency on QTP software.

Mercury.DeviceReplay :- It comes with QTP as a module, so you need QTP on the system and only from QTP action you can use it.
SendKeys :- It could be used in VBS script to simulate keyboard inputs with native windows shell commands. It has no dependency on QTP as such.

Out of Mercury DeviceReplay and SendKeys, which one should I use for Automation testing with QTP?

1. Depends on your objective like mouse operations & multilingual testing required.
2.In case of normal keyboard operations supported by both, SendKeys is easy to use due to English like syntax for keyboard input. Whereas for devicereplay you need to define user friendly names/constants (like VK_SHIFT etc) to numeric keycodes.

Friday, June 3, 2011

QTP 11 patch Slow Results Viewer

I have recently upgraded from QTP10 to QTP11 and after running a sample script in QTP11, I found that it took ages to open Results Viewer. Fortunately, there is a solution for this issue as well. HP has provided a hotfix RRV_00013. This patch will resolve the following issues:

1. Reduce the time to open large results in QTP11.
2. Reduce the time to export large run results in QTP11.
3. Fixed the issue where run results where not displayed correctly.
4. Fixed the issue when sometimes the run results viewer gets crashed.
5. Displays the data table in results for business process tests created using Quality Center 10.00.
6. This hotfix provides the support for multiple icon file types other than the standard .ico files. It supports *.jpg, *.gif and *.png.