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")
obj.click
wait 3
x1=obj.GetroProperty("x")
y1=obj.GetroProperty("y")
oDR.MouseClick x1,y1,2
Please note that 2 in above line is for Right click. [0=left; 1=middle; 2=right]
y1=obj.GetroProperty("y")
oDR.MouseClick x1,y1,2
Please note that 2 in above line is for Right click. [0=left; 1=middle; 2=right]
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.
ReplyDeleteIs it possible to open the webpages through right clicks,perform operation in that page and close that page?
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...
ReplyDeleteHi,,, PLz Help me...
ReplyDeletewhile i clicking link on any web page it shows label box , that contains "Open Link in New Tab, Open Link in New Window,......so on.. ", How can i click "Open Link in New Window" or any other links which is exists on that Label....
Test
Delete----------
SystemUtil.Run "iexplore.exe","http://www.google.com"
Wait(10)
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}")
FunctionLibrary
-----------------------
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
Thanks for info.
ReplyDeleteWe can use Fire event function to right click on any objects. For eg
ReplyDeleteSet 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