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.

Example:

strFound =Window(“”).Dialog(“”).GetTextLocation (“OK” ,x1,y1,x2,y2)
If strFound = True Then
       Window(“”).Dialog(“”).Click (x1+x2)/2 ,(y1+y2)/2
Else
       'Report a Failure
End If

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:

Window(“”).Dialog(“”).Clickontext “OK”,x1,y1,x2,y2,true,micRightbtn,false


Syntax for ClickOnText :
ClickOnText(TextToFind, Left, Top, Right, Bottom, MatchWholeWordOnly,ButtonToClick,DoubleClick)

Comments

Post a Comment

Popular posts from this blog

Software Testing @ Microsoft

Trim / Remove spaces in Xpath?