Can you record right click and the menu appearing after right clicking on any of the links in the browser...??If YES then HOW...??

Showing Answers 1 - 6 of 6 Answers

Uday Kumar. A

  • Sep 30th, 2006
 

We cannot record the right click operation. But we can achieve this by using below script. I had tried with this script, it is worked fine with me.

Set menu=browser("MSN.com").Page("MSN.com").Image("F430 (? Ferrari S.p.A.)")
idx=3 'This var. points the which option to select in the right click menu. This var. is always the option+1 value. Ex. If u want to select the second option then the  var. should have the value 3.
Set obj = CreateObject("Mercury.DeviceReplay")
Set WshShell = CreateObject("WScript.Shell")
'Get the absolute coordinates of the ibject
absx = menu.QueryValue("abs_x")
absy = menu.QueryValue("abs_y")

obj.MouseClick absx, absy, 2
'Optional wait statement
wait 3

For i = 1 To idx-1
WshShell.sendkeys "{DOWN}"
Next
WshShell.sendkeys "{ENTER}"
Set WshSEll = nothing
Set obj = nothing

sri

  • Oct 3rd, 2006
 

Yes, we can record right click events and select the links from that menu.

If u want to right click on a link that opens a menu

Browser(objBrowser).Page(objPage).Link(objText,objType).FireEvent "oncontextmenu"

This will open the right click menu,and if u want to select something from that menu

Browser(objBrowser).page(objPage).WebElement(objText,objType).Click

  Was this answer useful?  Yes

Aravindan

  • Nov 19th, 2007
 

I was trying similar functionality for right click on IE  window and trap right click view source.
it works more easier if you know your mouse coordinates for your shortcut menu item.
for example when i right click on ie at 682 180 (X,Y Coord) , QTP can record it as right click .

Window("Microsoft Internet Explorer").WinObject("Internet Explorer_Server").Click 682, 180, micRightBtn

then to click view source all i need is

Window("Microsoft Internet Explorer").Click 882, 513,micLeftBtn

Its true user might click anywhere for right click menu, however for your testing you can use fixed position and relative coordinates.

If you say, hey its tough to find the mouse coordinates, use paint , it shows the xy coordinates in status bar relative to screen, then you have an approximate position, try it out  ;)

  Was this answer useful?  Yes

abhatiwari

  • Jun 30th, 2008
 

Hi use the following function to do it

Sub RightMenuSelect (menu, idx)
   Set obj = CreateObject("Mercury.DeviceReplay")
   Set WshShell = CreateObject("WScript.Shell")
   x = menu.GetROProperty("abs_x")
   y = menu.GetROProperty("abs_y")
   obj.MouseClick x+5, y+5, 2
   For i = 1 To idx
       WshShell.sendKeys "{DOWN}"
   Next
   WshShell.sendKeys "{ENTER}"
   set WshShell = nothing
   Set obj = nothing
End Sub


Abha Tiwari

  Was this answer useful?  Yes

sayyed

  • Feb 2nd, 2012
 

I always get a general RUN error in the line
obj.MouseClick x+5, y+5, 2
Please advise...I tried to get the err number but unable to find a solution with that err number

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions