How to Execute Right Click an Object Using SendKeys in UFT?
On the Web, if an operation RightClick
does not achieve the expected results, it may be because UFT does not fire the sequence of events that the browser is expecting. You can say that UFT runs web tests using device replay, in which case it moves the mouse cursor to the desired location and simulates actual mouse clicks (including right-clicking).
See this answer or just follow these steps:
Setting.WebPackage("ReplayType") = 2 ' change to device replay mode
' Perform your right-click here
Setting.WebPackage("ReplayType") = 1 ' back to normal
source to share
you can do it in two ways.
1) By Object.Click
like ObjSomeObject.Click 1,1, micRightButton
2) By Repeating Mercury Device
To do this, get the properties abs_x and abs_y , Height, Width . compute them and get intDerivedxLocation AND intDerivedxLocation. Then do the 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
source to share
there is one keyboard shortcut right click Shift + F10. If we pass this through the send keys, we can do it. Before that, we must either hover over this object, or make it active by clicking on this object.
for example
Browser().page().webelement().click;
Browser().page().webelement().sendkeys "+F10";
source to share