Deep Patel: March 2012

Thursday, March 1, 2012

Right click on disabled (or any other object) in QTP

I recently faced a problem on one of the Java Tables.

The table as such was disabled(freezed!).
Which can be enabled by right clicking and selecting "unfreeze"

QTP internally doesn't perform operations on disabled objects so it gave me errors when I used

Browser("SwingSet demo").Page("SwingSet demo").JavaApplet("SwingSetApplet").JavaTable("Inter-cell spacing:").ClickCell 2, "Last Name", "RIGHT", "SHIFT"

QTP gives "Object Disabled" message box.

To get over this I used "Mercury.DeviceReplay" object.

Device level replay simulates mouse or key operations exactly as if they occur on the mouse or keyboard drivers. When a mouse action is simulated on device replay, the mouse pointer moves on the screen to the point where the action is to be performed during the test run.

Script Snippet Start

Set objRightClickMenu = CreateObject("Mercury.DeviceReplay")
objRightClickMenu.MouseClick intX, intY, 2
Set objRightClickMenu = nothing

Script Snippet End

Here intX and intY are absolute co ordinates where you want to perform the click.