Data Table in QTP
Data Table in QTP
Data table is simple excel kind of sheet with columns and rows which display data applicable to your
test. Data table will help you in parameterize your test.
To view data table Go to view->Data Table.
There are basically two kinds of data sheet one is Global sheet and other is local sheet (current action
sheet)
I am going to give you step by step procedure from scratch to end for how to use data table in your
application, so you will be more clearer about data table in QTP.
Please go through following procedure.
------------------------------------
SystemUtil.Run "http://google.com","","",""
Browser("Google").Page("Google").sync
Browser("Google").Close
------------------------------------
4. Now put cursor on second sentence and do right click on that sentence.
5. Select “Insert output value”, you will have window like following select all three properties and click
ok. By default all the values will go to global sheet. You can modify this setting by pressing “modify”
button and selecting local sheet.(Note: You can also redirect these values to environment table and you
can access it. know more about environment variable in qtp and how to load and export environment
variable in qtp ) Refer following figure for more clarity.
6. So you will have code like following.
------------------------------------
SystemUtil.Run "http://google.com","","",""
Browser("Google").Page("Google").Output CheckPoint("Google")
Browser("Google").Page("Google").sync
Browser("Google").Close
------------------------------------
7. So when you run the above script you can view three parameter and its value in global data sheet. If
you are not able to view, please go to view->Data Table.
8. You can view values during test run, you can’t view that value after test is over.
9. You can export these values in external file with help of datatable.export command.
Put following sentence at last in your script
Datatable.export(“c:\qtp.xls”)
10. You can also use datatable.import command to import external excel file to your test in the start of
test.
In addition to this you can also use datatable.getrowcount command to get row count in datatable. You
can also use addsheet, deleteSheet, getSheet, getSheetCount, setCurrentRow, setNextRow, setPrevRow
data table methods etc. You can use QTP help for more understanding on this kind of data table
commands.