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.
Dialog(“Login”).Activate
rem Click the “OK” button.
Dialog(“Login”).WinButton(“OK”).Click
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”
4 comments:
Well Said about ClickONText method.
Keep up the God work.
QTPbook
Actual hierarchy:
swfwindow().window().Page().Frame().Winbutton().Click
code: swfwindow().window().ClickonText “Next >”
When we use the above code "Clickontext" method, throwing “Compare Fail” error message.
Hi This methods supports only Window based application not working on Web Applications...
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