Thursday, February 9, 2012

Clicking at any point(x & y corodinates) on screen using qtp

Sometimes QTP do not identifies complex objects due to various reasons, in such case if you want to click on the unidentifiable object you can use following method. However you want to know the (x,y) position of that object in the browser/application.


Set obj=CreateObject("Mercury.DeviceReplay")
obj.MouseClick x,y,0

You can get the x & y coordinates of that object using the following code or you can use the approximation. This is also useful when QTP do not identify the methods associated/supported by any particular object.
e.g. There might be a webelement object which needs a click to activate, but QTP might not identify or support click method for that particular object then use following code to get the x & y coordinates of that object. Also note that the coordinates must be converted to integer subtype before passing into MouseClick method.


x=Browser("micclass:=Browser").Page("micclass:=Page").WebElement("innertext:=property").GetROProperty("abs_x") 
y=Browser("micclass:=Browser").Page("micclass:=Page").WebElement("innertext:=property").GetROProperty("abs_y") 
x= cint(x)
y= cint(y)



Set obj=CreateObject("Mercury.DeviceReplay")
obj.MouseClick x,y,0



1 comment: