I have a data driven QTP test script that retrieves input parameters from an Excel File. Is there a way to actually write the results of the test into that Excel file, as well?
For instance,
My input file has the following Columns:
- User ID
- Password
- Login Result
The test script uses the User ID and Password are the input parameters to login to the system. The script then checks whether the login attempt was successful and then should write the result alongside in the Login Result column.
Depends on how you have created your interfacing to Excel. If you use the Excel COM object (like
Set objExcel = CreateObject("Excel.Application")) than it is certainly possible:See some basic scripts at ActiveExperts.com if you need examples.
I have some bad experience with datatables in QTP (but I may be biased), that is why I do not use them. I do not know if two way communication with Excel is possible in QTP with the use of the build in datatables.
EDIT
See the QTP Help file how to do this with the build in datatables. It clearly says:
ExportSheet Method
Description
Exports a specified sheet of the run-time Data Table to the specified file.
If the specified file does not exist, a new file is created and the specified sheet is saved.
If the current file exists, but the file does not contain a sheet with the specified sheet name, the sheet is inserted as the last sheet of the file.
If the current file exists and the file contains the specified sheet, the exported sheet overwrites the existing sheet.
Syntax
DataTable.ExportSheet(FileName, DTSheet)
Example
The following example uses the ExportSheet method to save the first sheet of the run-time Data Table to the name.xls file.