Sunday 6 July 2014

How to click on the buttons in table cells in QTP?

In software testing projects, many times we come across situations where we have to perform the operation on the objects relative to other objects. For example - in below table we have three view buttons. So to click on the view button for given emp id, you will have to first find the row number in which that emp id exists and then click on the view button in that row.
                     Emp Id                                Action                     
78989
7777
9999

We can use HTML DOM concept to handle such situations.
We can find the TD element which contains employee id say 7777. After this, we can use nextSibling property of the TD element to get the Next TD element and then find the child object (Button) of that TD using getElementsByName method.

In windows based applications, we can use relative identifier (Supported in QTP 11.5 onwards and UFT).

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com

How to connect to sql server in QTP

Connecting to sql server is easy in QTP. In below example, we have connected to sql server.
The name of database is empdb. We have created a DSN called sqlserver.

'fetch data from database
Set db = createobject("ADODB.Connection")
'open the connection to empdb database.

db.Open "DSN=sqlserver;Database=empdb"
'create record set object

Set rst = createobject("ADODB.Recordset")
'fire the query

rst.Open "select * from emp", db,3
id = rst.RecordCount
For i=0 to id-1
'read data from table

print rst.fields(0) & rst.fields(1)
rst.Movenext
Next

Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts. You can write to me at reply2sagar@gmail.com

Best QTP Books

Everything About QTP

Hello Friends,
You can find QTP study material, Multiple choice questions (mcq), QTP question bank, QTP question papers, QTP notes, QTP questionnaire, scenario based QTP interview questions, QTP tutorial and QTP training on this site.

If you are a fresher or experienced QTP professional with (1/2/3/4) years of experience, this blog is just for you.