An UFT DataTable is similar like a Microsoft Excel DataTable that benefits developer and testers to generate data driven test cases that can be used to run an Action multiple times.
There are two Types of DataTables in UFT/QTP.
- Local DataTable–For each action there is a private DataTable known as local DataTable that can also be opened across actions.
- Global DataTable–For testing there is a global data sheet that can be used for multiple actions.
Insert DataTable parameters and output values into the test. The DataTable parameters and/or output values generate a data-driven test or action during the test, runs several times using the data you supply.
In UFT, click on the “Data” Tab to access Data sheet as shown below,
To run a test case for certain iterations, one can set the iterations of global DataTable in the Test Settings dialog, that can be accessed using File -> Settings -> Run(Tab) as shown below:
How to Uses DataTables in UFT/QTP:
For different-different process (Repetition, iteration, or run session) UFT uses different values from DataTable. During run time, UFT generates a run-time DataTable is a live version of the DataTable linked with the test. Also, UFT Data pane shows all run-time data makes easier for others to see data when any changes happen in the DataTable. During the end of the run time, the run-time DataTable ends and the Data pane again shows the stored design-time DataTable. The run time data does not get saved with the test and Results Viewer displays the final data from the run-time DataTable.
How to Save DataTable in UFT/QTP
During the test, the DataTable values get saved with the test by default in“.xls”or “.xlsx”file format.
You can also save the DataTable in another location and guide the test to use this DataTable when running a test.
Too save the data from the run-time DataTable, insert a DataTable.Export statement to the end of your test to export the run-time DataTable to a file. Also, can import the data to the design-time DataTable from DataTable’s File > Import from File menu. Alternatively, DataTable.Importstatement can be added at the beginning of the test to import the run-time DataTable.
DataTable Processes
There are three types of objects works on DataTable, shown in the given below table,
DataTable Object Methods:
Method Name | Description | Syntax |
Export | Exports the DataTable to a new file in the specified location | Exports the DataTable to a new file in the specified location |
DeleteSheet | Deletes the specified sheet from the run-time DataTable | DataTable.DeleteSheetSheetID |
AddSheet | Adds the specified sheet to the run-time DataTable | DataTable.AddSheet(SheetName) |
ExportSheet | Exports a Specific Sheet of the DataTable in run-time | DataTable.ExportSheet(FileName,SheetName) |
GetSheetCount | Returns the total number of sheets in the run-time DataTable. | DataTable.GetSheetCount |
GetSheet | Returns the specified sheet from the run-time DataTable. | DataTable.GetSheet(SheetID) |
GetRowCount | Returns the number of rows in the run-time DataTable of Global Sheet | DataTable.GetRowCount |
GetParameterCount | Returns the number of columns in the run-time DataTable of Global Sheet | DataTable.GetParameterCount |
GetCurrentRow | Returns the active row of the run-time DataTable of global sheet | DataTable.GetCurrentRow |
SetPreviousRow | Sets the focus of the previous row in the run-time DataTable | DataTable.SetPrevRow |
SetCurrentRow | Sets the Focus of the Current row to the Specified Row Number | DataTable.SetCurrentRow(RowNumber) |
SetNextRow | Sets the focus of the next row in the run-time DataTable | DataTable.SetNextRow |
ImportSheet | Imports the specified sheet of the specific excel file to the destination sheet. | DataTable.SetCurrentRow(RowNumber) |
Import | Imports a specific external Excel file to the run-time DataTable. | DataTable.Import(FileName) |
DataTable Object Properties:
Property Name | Description | Syntax |
GlobalSheet | Returns the first sheet of the run-time DataTable. | DataTable.GlobalSheet |
LocalSheet | Returns the Active local sheet of the run-time DataTable. | DataTable.LocalSheet |
RawValue | Retrieves the raw value of the cell | DataTable.RawValueParameterID, [SheetID] |
Value | Retrieves the value of the cell in the specified parameter. | DataTable.Value(ParameterID, [SheetID]) |
DataTable Parameter Object Properties:
Method Name | Description | Syntax |
Name | Returns the name of the parameter in the run-time DataTable. | DTParameter.Name |
Value | Retrieves or sets the value of the cell in the Active row of the parameter in the run-time DataTable. | DTParameter.Value |
ValueByRow | Retrieves the value of the cell in the specified row of the parameter in the run-time DataTable. | DTParameter.ValueByRow(RowNum) |
RawValue | Returns the raw value of the cell in the current row of the run-time DataTable. | DTParameter.RawValue |
DataTable Sheet Methods:
Method Name | Description | Syntax |
GetRowCount | Returns the total number of rows in the run-time DataTable | DTSheet.GetRowCount |
GetParameterCount | Returns the total number of Columns in the run-time DataTable. | DTSheet.GetParameterCount |
GetParameter | Returns the specified parameter from the run-time DataTable | DTSheet.GetParameter(ParameterID) |
GetCurrentRow | Returns the row number of the active row in the run-time DataTable. | DTSheet.GetCurrentRow |
SetNextRow | Shifts the Focus to the next Row of the DataTable. | DTSheet.SetNextRow |
SetPrevRow | Shifts the Focus to the Previous Row of the DataTable. | DTSheet.SetPrevRow |
SetCurrentRow | Sets the Focus on the specified Row of the DataTable | DTSheet.SetCurrentRow(RowNumber) |
DeleteParameter | Deletes the specified parameter from the run-time DataTable. | DTSheet.DeleteParameter(ParameterID) |
AddParameter | Adds the specified column to the sheet in the run-time DataTable. | DTSheet.AddParameter(ParameterName,Value) |
⇓ Subscribe Us ⇓
If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:
Happy Testing!!!