Thursday, 4 August 2011

Get Text Location / ClickOnText QTP VB

Hi All,
Now I am going to describle the undocumented feature of QTP that is ClickONText  method . Some time we require the object text location ( x ,y position ) in window so that we can click  that object by use  Get text location method. like this
rem  Open the “C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe” application.
SystemUtil.Run “C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”,”C:\Program Files\HP\QuickTest Professional\samples\flight\app\flight4a.exe”,”"
rem   Make the “Login” dialog box active.

rem  Click the “OK” button.


rem Check whether the text “OK” is displayed in the “Flight Reservations” dialog box and store the location of the text in rem    arguments 2-5. Store the result in the variable ‘find’
find =Dialog(“Login”).Dialog(“Flight Reservations”).GetTextLocation (“OK” ,x1,y1,x2,y2)
rem Check whether (find = True) is true. If so:
If find =True  Then
Dialog(“Login”).Dialog(“Flight Reservations”).Click  (x1+x2)/2 ,(y1+y2)/2 rem Click the “Flight Reservations” ‘dialog box
else rem Otherwise:
msgbox  “not found OK text”
End If

Instead of Serached the text location in Window we can use directely method ClickonText like this it will automatically search the text and click the text area

Dialog(“Login”).Dialog(“Flight Reservations”).Clickontext “OK”


QPT said...

Well Said about ClickONText method.
Keep up the God work.


Anonymous said...

Actual hierarchy:

code: swfwindow().window().ClickonText “Next >”
When we use the above code "Clickontext" method, throwing “Compare Fail” error message.

Anonymous said...

Hi This methods supports only Window based application not working on Web Applications...

devesh said...

This method is only use for find a button text, can it be use for find a label text or text contain

Post a Comment

Which one is right ?