This is a group, where all the QTP Professionals can join and share there knowledge by posting the Queries or answering the queries.

Members: 294
Latest Activity: Jun 7

Different Ways to click a button

Here i am giving an idea of how we can write the scripts in different ways..
Here i am taking an example in how many ways we can write a statement to click on a specified button.
I took two conditions first one is when we are using object repository, second one is when we are not using object repository
(Using Descriptive programming) .

Using Object Repository

'1st method
Window("Flight Reservation" ).WinButton( "Update Order").Click 'Common Method

'2nd method
Set wndObject=Window( "Flight Reservation" ) ' Assigning window object to an object variable
wndObject.WinButton ("Update Order").Click ' Following normal syntax ( click on a button)

' OR

Set btnObject=Window( "Flight Reservation" ).WinButton( "Update Order") ' Assigning Button object to an object variable
btnObject.Click ' Clicking on button using button object variable

'3rd method

With Window("Flight Reservation" ) ' Using With statement
.WinButton(" Update Order").click
End with

Using Descriptive Programming

'4th method

Window("text: =Flight Reservation" ).WinButton( "text:=&Update Order").Click ' Descriptive programming

'5th method

Set oDes=Description. Create ' creating a description object
oDes("nativeclass" ).value=" Button" ' assigning description to the description object
oDes("text") .value="&Update Order"
Window("text: =Flight Reservation" ).winbutton( oDes).click ' clicking on button using the created description object

'6th method

Set oDes=Description. Create ' creating a description object

set btnObjList=Window( "text:=Flight Reservation" ).ChildObjects( oDes) ' Flitering the objects
For objIndex=0 to btnObjList.count- 1
propVal=btnObjList( objIndex) .getroproperty( "text") ' Get property value from object
If propVal="&Update Order" Then ' Compare property value
btnObjList(objIndex ).click ' Click on identified object
Exit for ' Exit For loop after clicking on the button
End If

'7th method

Public const wndFlight="text: =Flight Reservation" ' Assigning window object description to a constant
Public const btnUpdate="text: =&Update Order" ' Assigning Button object description to a constant

Window(wndFlight) .winbutton( btnUpdate) .click ' Click on a button using description constants

Discussion Forum

Unable to focus on Wpf Object

Started by Sushanth Dec 26, 2013.


Started by QTP Help Feb 3, 2012.

Comment Wall


You need to be a member of QTPPro to add comments!

Comment by Deepak Pesumalani on February 4, 2011 at 4:46pm

Vbscript Function Related to Date:

Playing with Array:
Data Type Validation in Vbscript :
Creating dictionary using Vbscript:





Friend please visit and let me know your comments & query

Comment by Ragavan on January 12, 2011 at 3:41pm
I have a prob to write the below script. some one can help how to
handle it.
In a webtable there are 10 records available and i want to edit the
record randomly or one by one. every record have edit/delete button
Set objedit=description.Create()
objedit("image type").value="Image Button"
objedit("file name").value="Edit_bnt.jpg"
a=Browser("Brw_seach").Page("Pg_search").WebTable("FestivalName").ChildObje cts(objedit)
MsgBox listofeditbtn
Loop UNTIL listofeditbtn
Comment by Badari nath manda on January 12, 2011 at 2:48pm
Thanks Deepak,can you tell me any site which provides best video's regardong qtp
Comment by Deepak Pesumalani on January 12, 2011 at 2:43pm

For QTP related queries one can go through..

Comment by akshar jain on January 12, 2011 at 11:12am
Its 30 seconds
Comment by Badari nath manda on January 12, 2011 at 9:56am
Q. The object synchronization timeout (Test > Settings > Run tab) setting is 
set to 20,000 milliseconds (20 seconds).

Consider the following statement: 

JavaWindow("Trade Manager").JavaDialog("Trade 
Entry").JavaButton("Enter").Exist 10

What is the maximum amount of time the statement will wait for the 
specified object to appear?

A 20 seconds 

B 10 seconds 

C 30 seconds 

D 10 milliseconds 

E 20,010 milliseconds
Comment by Badari nath manda on January 11, 2011 at 12:15pm
QTP 10.0
Comment by akshar jain on January 11, 2011 at 11:36am

Hi Badari, Let me know which version of QTP u r using... If u r using QTP-10 then u can go to Resources tab n click on Associate Respoitories.. Again u need to know whether u need to go for hard coded Absolute path or Relative path..

Comment by Badari nath manda on January 11, 2011 at 8:40am

Hi friends,

   Please suggest me how to use associate repository,split action..

Comment by Rengarajan Rajesh on December 30, 2010 at 10:47pm

Hi Friends,

Currently i'm working in a Flex application where i'm facing a problem in selecting a menu through right-click.


More Clearly,Need to select an item by doing a right click.Recorded this and observed that right-click is missing in recording and here ,qtp is failing to re-play as right-click option is not working.




Set Obj = Browser("").FlexApplication("").FlexDividedBox("").FlexTree("")

Set Obj1 = CreateObject("Mercury.DeviceReplay") 
Set WshShell = CreateObject("WScript.Shell")
absx = Obj.QueryValue("abs_x")
absy = Obj.QueryValue("abs_y")
Obj1.MouseClick absx, absy, 2

For i = 1 To 2
WshShell.sendkeys "{DOWN}"
WshShell.sendkeys "{ENTER}"


Tried with the above but it is clicking near to that and the expected menu didn't appear.Trying in getting the proper values to make qtp to select the right link.

Help me friends


Members (294)


© 2014   Created by Test Republic.

Badges  |  Report an Issue  |  Terms of Service