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
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)


  1. Anonymous14/1/11

    Thnx for the syntax!

  2. "ClickonText" will work on .Net & WebApplications?


Post a Comment

Popular posts from this blog

Trim / Remove spaces in Xpath?

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath