ClickOnText in QTP
There are times when QTP forces us to use alternative methods to try and access objects which are not recognized as standard objects, and do not fall under any Class in QTP.
One such method is the "GetTextLocation" used in conjunction with the "Click" method.
strFound =Window(“”).Dialog(“”).GetTextLocation (“OK” ,x1,y1,x2,y2)
If strFound = True Then
Window(“”).Dialog(“”).Click (x1+x2)/2 ,(y1+y2)/2
'Report a Failure
How about replacing the above code with just one line of code that does everything internally to get the x1,y1,x2,y2 co-ordinates and gives us options to choose left/right, single/double click.
Here you go:
Syntax for ClickOnText :
ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly,ButtonToClick,DoubleClick)