Micro Focus QTP (UFT) Forums
How to implement Mouse Right button - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: How to implement Mouse Right button (/Thread-How-to-implement-Mouse-Right-button)



How to implement Mouse Right button - Ravi_Chandra - 01-18-2011

Hi,

As part of the application functionality, we have to righ click a record and select one of the options.

Can anyone provide a solution on how to write the code so that QTP can right click a record and select one of its options?

Thanks,
Ravi.


RE: How to implement Mouse Right button - PrabhatN - 01-18-2011

Hi Ravi,

You have mentioned that you have to right click on a record. What exactly a record is here? I mean is it a link or table content or what?

I presume that it is a link and let say it has a name "Record1". After clicking the right mouse button, let say the menu comes is a WebElement. Below code may solve your purpose,

Code:
Set dReplayObj = CreateObject("Mercury.DeviceReplay")// Create an object of DeviceReplay

get_X = Browser("").Page("").Link("Record1").GetROProperty("abs_x")// Get X axis value of Record1

get_Y = Browser("").Page("").Link("Record1").GetROProperty("abs_y")// Get Y axis value of Record1

dReplayObj.MouseClick get_X,get_Y,RIGHT_MOUSE_BUTTON// Right click on the Record1

Browser("").Page("").WebElement("Menu").Click// Chose any option

You can spy on the objects, know the class types and then customize the above code accordingly.

Let me know for further clarification.


RE: How to implement Mouse Right button - Ravi_Chandra - 01-19-2011

Hi Prabhat,

I have a data grid where
I have to search the record (webelement)
select the record
right click on it and
select the options from the right click menu.

I am able to get webelement using the below code:
Quote:Browser("XXX").Page("YYY").WebElement("ABC").SetToProperty "innertext", "abcd"
Browser("XXX").Page("YYY").WebElement("ABC").Click

Now I have to right click on this webelement....
Can you help me how can i achieve this?

Thanks,
Ravi.


RE: How to implement Mouse Right button - Saket - 01-19-2011

See if any of this thread helps you-
https://www.learnqtp.com/forums/archive/index.php/thread-2356.html
https://www.learnqtp.com/forums/Thread-Right-Click-on-menu-in-Web-Table
or you may try this -
Code:
Dim strObj
set strObj = browser("Google").Page("Google")
x_coord = strObj.GetROProperty("abs_x")

y_coord = strObj.GetROProperty("abs_y")

Set objDr = CreateObject("Mercury.DeviceReplay")

objDr.MouseClick x_coord, y_coord, 2
Dim WshShell
set WshShell = CreateObject("WScript.Shell")
Dim i ,n
For i = 0 to 14
If i = 12 Then
wshshell.sendkeys "{ENTER}"
For n = 0 to 6
If n = 5 Then
wait(1)
wshshell.sendkeys "{ENTER}"
Exit for
else
wshshell.sendkeys "{DOWN}"
End If
Next
Exit for
else
wshshell.sendkeys "{DOWN}"
End If
Next



RE: How to implement Mouse Right button - MailJayAbhi - 01-19-2011

Hi Ravi,

Since you say that you have the Webelement , The simplest way to achieve this is
1.Use the Focus option onto the Webelement
2.Click on Shift+F10.

This is a easier way and can be put in a loop as well.

I hope this Helped.