QTP Tutorials 2 – Using Data Table
In our next example we will use data table:
There are two types of data tables Design time and Run time:
Design time data table is what you see in the main QTP window and run time data table you can see only in the test results window. Design time data table is always created before running the test while run time data table is generated after execution of the test.
1) Open new test (Ctrl+N)
2) We will click on record toolbar button ( or Automation menu –> record or press F3). when we click on record, “Record and Run Settings” window opens up. Go to “Windows Applications” tab and choose first option “Record and run test on any open windows based application.” and click on ok.
3) Open Flight application (Start–>All programs–>QuickTest Professional->Sample Applications–>Flight)
4) Type Agent name as “Kumar” (you can enter any, but must be 4 characters or more) and enter password as “mercury”.
5) In the flight reservation window that opens up:
6) Click on File–>exit. Click Stop to stop the recording.
7) In the keyword view you will see four headings- Item, Operation, Value, Documentation. Under Value click on Kumar and on the right hand side of Kumar you will see a small icon, just click on that (or press ctrl + F11), The “Value Configuration Options” dialog box opens. In that dialog box click on parameter radio button and select Data Table from there. In Name field enter any variable name (I entered ‘username’). Let all other be the default options in this dialog box and click on ok.
8) QTP will add username column in the data table (bottom, left hand side) with ‘Kumar’ as the first value.
9) Now enter more values in the username column, manually. I entered ‘Sachin’ and ‘Sunil’ in 2nd and 3rd column respectively.
10) Save the test. (File–>Save).
11) Now run the test. (follow same steps as we did earlier).
12) If the test ran successfully, in the Results summary window on the left hand side you will see three iterations (because we added 3 variables in the 3 rows of a data table). Expand 1st iteration, it will show action summary for that iteration, expand the action summary, it will show Login, Expand the login. Click on the first option under it “Agent Name: SetText”. On the right hand side it will show 1st variable name under details.
13) Similarly you can look for 2nd and 3rd.