You can’t actually modify the data permanently in the datatable associated with the test script during a test run but there are two approaches you can take in order to save the data into an external file that you can use later. During “run-time” a copy of the datatable is created as the “run-time datatable” and anything you write to the datatable is actually stored in this “run-time table” which is actually another instance of the datatable saved with the Test Run. This has its Pros and Cons depending on how you look at it. Regardless of your view if you want to permanently save your test data then you basically have two choices:
- You can use the “DataTable.Export” method or “DataTable.ExportSheet” method to literally create a new .xls file of the workbook or specified worksheet, and have this new file saved in your file system (locally or on the network). With this approach you can then use that datatable/spreadsheet however you want including importing it into the permanent datatable attached to the test script if you want.


- Also keep in mind that your Test Results Report will show you the data used and created during the test run. You can view this in the “Data Table” in the test report itself.

You can then export that data into an external file too, from the report. The steps are slightly different depending on the version of QTP you are using, but from QTP v11 you would simply select “File > Export to File…” and then select “Data Table” from the “Report type” drop-down list. When you click the “Export” button you can then specify a new name and location for the data file (.xls). This will export ALL the data in the datatable (all the worksheets will be exported this way). Like the previous approach, you now have an external .xls file that you can now do whatever you want with it, including importing it back into the permanent datatable attached to the test script.


Category:
Tags: 