Nitish Aggarwal
Nitish Aggarwal

Reputation: 567

How to perform Right Click on an object using SendKeys in UFT?

I want to perform a Right Click on an object in my Application Under Test but I am not able to perform this action. Is there any way to do it using sendkeys?

Upvotes: 3

Views: 8927

Answers (3)

dhulipala murali
dhulipala murali

Reputation: 193

there is one shortcut for Keyboard right click Shift+F10. If we pass this through send keys then we can able to do this.before doing this we have to either mouse over on that object or we have make that active by clicking on that object.

for Example

Browser().page().webelement().click;
Browser().page().webelement().sendkeys "+F10";

Upvotes: 0

suman maiti
suman maiti

Reputation: 46

you can do it in two ways.

1) By Object.Click

like ObjSomeObject.Click 1,1,micRightButton

2) By Mercury Device Replay

For This Get abs_x And abs_y,Height,Width properties. calculate them and derive intDerivedxLocation AND intDerivedxLocation. Then perform following

intabsX = objApp.getRoProperty("abs_x")

intabsY = objApp.getRoProperty("abs_y")

intHeight = objApp.getRoProperty("height")

intWidth = objApp.getRoProperty("width")

intDerivedxLocation= Cint(intabsX) +Cint(intWidth /2)

intDerivedxLocation= Cint(intabsY) +Cint(intHeight/2)

Dim objMercuryDeviceReplay

Set objMercuryDeviceReplay= CreateObject("Mercury.DeviceReplay")

objMercuryDeviceReplay.MouseClick intDerivedxLocation, intDerivedxLocation, 2

Upvotes: 0

Motti
Motti

Reputation: 114805

In Web, if the RightClick operation doesn't achieve the expected results this may be because UFT doesn't fire the sequence of events that the browser is expecting. You can tell UFT to run Web tests using device replay in which case it will move the mouse cursor to the correct location and simulate actual mouse clicks (including right-click).

See this answer, or just do the following:

Setting.WebPackage("ReplayType") = 2 ' change to device replay mode
' Perform your right-click here
Setting.WebPackage("ReplayType") = 1 ' back to normal

Upvotes: 0

Related Questions