Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to implement Mouse Right button
#1
Solved: 11 Years, 4 Months ago
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.
Reply
#2
Solved: 11 Years, 4 Months ago
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.
Reply
#3
Solved: 11 Years, 4 Months ago
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.


Attached Files Image(s)
   
Reply
#4
Solved: 11 Years, 4 Months ago
See if any of this thread helps you-
https://www.learnqtp.com/forums/archive/...-2356.html
https://www.learnqtp.com/forums/Thread-R...-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

Reply
#5
Solved: 11 Years, 4 Months ago
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.


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting background color of an object on mouse over Surya 2 3,904 06-27-2018, 08:51 PM
Last Post: vensas3181
  How to get the links which appears on mouse hover of parent link rajendra649 9 35,598 03-10-2017, 06:35 PM
Last Post: satish00k
  How to capture operation such as hovering a mouse nikhilcogni 5 4,762 03-23-2013, 11:17 AM
Last Post: sams001
  [QTP]Keyboard control + mouse click lucieclaire 2 23,014 12-18-2012, 03:11 PM
Last Post: lucieclaire
  How to implement mousemove method silpavinod 0 3,685 10-10-2012, 12:19 PM
Last Post: silpavinod

Forum Jump:


Users browsing this thread: 7 Guest(s)