简体   繁体   中英

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 ?

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

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

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";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM