Software Testing Class

UFT Datatable – UFT/QTP Training Tutorial 12

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.

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.

UFT Datatable

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 NameDescriptionSyntax
ExportExports the DataTable to a new file in the specified locationExports the DataTable to a new file in the specified location
DeleteSheetDeletes the specified sheet from the run-time DataTableDataTable.DeleteSheetSheetID
AddSheetAdds the specified sheet to the run-time DataTableDataTable.AddSheet(SheetName)
ExportSheetExports a Specific Sheet of the DataTable in run-timeDataTable.ExportSheet(FileName,SheetName)
GetSheetCountReturns the total number of sheets in the run-time DataTable.DataTable.GetSheetCount
GetSheetReturns the specified sheet from the run-time DataTable.DataTable.GetSheet(SheetID)
GetRowCountReturns the number of rows in the run-time DataTable of Global SheetDataTable.GetRowCount
GetParameterCountReturns the number of columns in the run-time DataTable of Global SheetDataTable.GetParameterCount
GetCurrentRowReturns the active row of the run-time DataTable of global sheetDataTable.GetCurrentRow
SetPreviousRowSets the focus of the previous row in the run-time DataTableDataTable.SetPrevRow
SetCurrentRowSets the Focus of the Current row to the Specified Row NumberDataTable.SetCurrentRow(RowNumber)
SetNextRowSets the focus of the next row in the run-time DataTableDataTable.SetNextRow
ImportSheetImports the specified sheet of the specific excel file to the destination sheet.DataTable.SetCurrentRow(RowNumber)
ImportImports a specific external Excel file to the run-time DataTable.DataTable.Import(FileName)

DataTable Object Properties:

Property NameDescriptionSyntax
GlobalSheetReturns the first sheet of the run-time DataTable.DataTable.GlobalSheet
LocalSheetReturns the Active local sheet of the run-time DataTable.DataTable.LocalSheet
RawValueRetrieves the raw value of the cellDataTable.RawValueParameterID, [SheetID]
ValueRetrieves the value of the cell in the specified parameter.DataTable.Value(ParameterID, [SheetID])

DataTable Parameter Object Properties:

Method NameDescriptionSyntax
NameReturns the name of the parameter in the run-time DataTable.DTParameter.Name
ValueRetrieves or sets the value of the cell in the Active row of the parameter in the run-time DataTable.DTParameter.Value
ValueByRowRetrieves the value of the cell in the specified row of the parameter in the run-time DataTable.DTParameter.ValueByRow(RowNum)
RawValueReturns the raw value of the cell in the current row of the run-time DataTable.DTParameter.RawValue

DataTable Sheet Methods:

Method NameDescriptionSyntax
GetRowCountReturns the total number of rows in the run-time DataTableDTSheet.GetRowCount
GetParameterCountReturns the total number of Columns in the run-time DataTable.DTSheet.GetParameterCount
GetParameterReturns the specified parameter from the run-time DataTableDTSheet.GetParameter(ParameterID)
GetCurrentRowReturns the row number of the active row in the run-time DataTable.DTSheet.GetCurrentRow
SetNextRowShifts the Focus to the next Row of the DataTable.DTSheet.SetNextRow
SetPrevRowShifts the Focus to the Previous Row of the DataTable.DTSheet.SetPrevRow
SetCurrentRowSets the Focus on the specified Row of the DataTableDTSheet.SetCurrentRow(RowNumber)
DeleteParameterDeletes the specified parameter from the run-time DataTable.DTSheet.DeleteParameter(ParameterID)
AddParameterAdds 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:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 
Exit mobile version