Data table in QTP
What is 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)
Practical example of Data table in QTP
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.
1. Press “Record” button.
2. Go to start->run write http://google.com and click OK.
3. close the internet explorer window, you will have code like following.
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.
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
10. You can also use datatable.import command to import external excel file to your test in the start of test.
How to use values in data table during run time in QTP?
You can do so using datatable.value command. For e.g.
intLink = datatable.value (“Google_number_of_links_out”)
Values from “Google_number_of_links_out” parameter will be stored in intLink variable.
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.
Let us know if you have any doubts on data table in QTP, You are always welcome to share your valuable thoughts and feedback.