Saturday, April 9

How to right-click on any object using QTP

Hello Friends!
Following code demonstrate how to right click on a particular object using QTP.
We'll use DeviceRepaly object to do that..

Dim oDR
Set oDR=CreateObject("Mercury.DeviceReplay")
Set obj=Browser("name:=Yahoo.*").Page("title:=Yahoo.*").Webedit("name:=p")
wait 3
oDR.MouseClick x1,y1,2

Please note that 2 in above line is for Right click. [0=left; 1=middle; 2=right]


  1. A drop down has module 1.On placing the cursor on module 1, sub-module opens for this,let's name them as module 1.1,module 1.2 and so on. I tried taking the getROProperty for a property,but script is unable to open the pages as we do with right clicks.
    Is it possible to open the webpages through right clicks,perform operation in that page and close that page?

  2. When you say.. "I tried taking the getROProperty for a property,but script is unable to open the pages"... what exactly you mean? please provide some more information on this...

  3. Hi,,, PLz Help me...
    while i clicking link on any web page it shows label box , that contains "Open Link in New Tab, Open Link in New Window, on.. ", How can i click "Open Link in New Window" or any other links which is exists on that Label....

    1. Test
      SystemUtil.Run "iexplore.exe",""
      x1 =Browser("creationtime:=0").Page("title:=.*").Link("name:=Français").GetROProperty("x")
      y1 =Browser("creationtime:=0").Page("title:=.*").Link("name:=Français").GetROProperty("y")

      Call PerformRightClick(x1,y1)
      Call SendKeys("{DOWN}")
      Call SendKeys("{DOWN}")
      Call SendKeys("{ENTER}")

      Function PerformRightClick(x1,y1)
      Set ODR = CreateObject("Mercury.DeviceReplay")
      ODR.MouseClick x1,y1,RIGHT_MOUSE_BUTTON
      End Function
      Function SendKeys(key)
      Set Obj = CreateObject("Wscript.Shell")
      Obj.SendKeys key,1
      End Function

  4. We can use Fire event function to right click on any objects. For eg

    Set mypage=browser("creationtime:=0").page("title:=.*")
    Mypage.webelement("class:= sdf").fireevent rgtbutton, 1
    This code cn be used , if u want to right clickmon any objects

  5. Your post is very old about blogging. Kindly share more tips about blogging. I am waiting for your new post. Then I will bookmark it.
    dissertation Writing Service