Automation Testing Tutorial | Data Table Basics & Operations

When you test your applications, you may want to check how the application performs the same operations with multiple sets of data. For example, suppose you want to check how your Web site responds to ten separate sets of data. You could create ten separate tests, each with its own set of data. Alternatively, you can create Data Table parameters so that your test runs ten times, each time using a different set of data

A Data Table, similar to Microsoft Excel helps testers to create data driven test cases that can be used to run an Action multiple times. There are two types:

  • Local Data Table – Each action has its own private data table also known as local data table which is can also be accessed across actions.
  • Global Data Table – Each test has one global data sheet-that is accessible across actions.

The Data sheet can be accessed from the “Data” Tab of QTP as shown below:

qtp datatable

To execute a test case for some specified number of iterations, one can set the iterations of global data table in the Test Settings dialog, that can be accessed using File -> Settings -> Run(Tab) as shown below

qtp datatable

Data Table Operations

There are three types of objects to access Data Table.Operations can be well understood by traversing through the below brief

 

Object Type Description
Methods Gives Detailed information about the data table methods.
DTParameter Object Methods Gives Detailed information about the DTParameter methods.
DTSheet Object Methods Gives Detailed information about the DTSheet methods.

Data Table Object Methods

Method Name Description Syntax
AddSheet Adds the specified sheet to the run-time data table DataTable.AddSheet(SheetName)
DeleteSheet Deletes the specified sheet from the run-time data table DataTable.DeleteSheet SheetID
Export Exports the Datatable to a new file in the specified location DataTable.Export(FileName)
ExportSheet Exports a Specific Sheet of the Datatable in run-time DataTable.ExportSheet(FileName,SheetName)
GetCurrentRow Returns the active row of the run-time data table of global sheet Data Table.GetCurrentRow
GetParameterCount Returns the number of columns in the run-time data Table of Global Sheet Data Table.GetParameterCount
GetRowCount Returns the number of rows in the run-time data table of Global Sheet DataTable.GetRowCount
GetSheet Returns the specified sheet from the run-time data table. DataTable.GetSheet(SheetID)
GetSheetCount Returns the total number of sheets in the run-time data table. DataTable.GetSheetCount
Import Imports a specific external Excel file to the run-time data table. DataTable.Import(FileName)
ImportSheet Imports the specified sheet of the specific excel file to the destination sheet. DataTable. ImportSheet(FileName, SheetSource, SheetDest)
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 data table DataTable.SetNextRow
SetPreviousRow Sets the focus of the previous row in the run-time data Table DataTable.SetPrevRow

Data Table Object Properties

Property Name Description Syntax
GlobalSheet Returns the first sheet of the run-time data table. DataTable.GlobalSheet
LocalSheet Returns the Active local sheet of the run-time data table. DataTable.LocalSheet
RawValue Retrieves the raw value of the cell DataTable.RawValue ParameterID, [SheetID]

 

Value Retrieves the value of the cell in the specified parameter. DataTable.Value(ParameterID, [SheetID])

DTParameter Object Properties

Method Name Description Syntax
Name Returns the name of the parameter in the run-time data table. DTParameter.Name
RawValue Returns the raw value of the cell in the current row of the run-time data table. DTParameter.RawValue
Value Retrieves or sets the value of the cell in the Active row of the parameter in the run-time data table. DTParameter.Value
ValueByRow Retrieves the value of the cell in the specified row of the parameter in the run-time data table. DTParameter.ValueByRow(RowNum)

DTSheet Methods

Method Name Description Syntax
AddParameter Adds the specified column to the sheet in the run-time data table. DTSheet.AddParameter(ParameterName, Value)
DeleteParameter Deletes the specified parameter from the run-time data table. DTSheet.DeleteParameter(ParameterID)
GetCurrentRow Returns the row number of the active row in the run-time Data Table. DTSheet.GetCurrentRow
GetParameter Returns the specified parameter from the run-time Data Table. DTSheet.GetParameter(ParameterID)
GetParameterCount Returns the total number of Columns in the run-time Data Table. DTSheet.GetParameterCount
GetRowCount Returns the total number of rows in the run-time Data Table. DTSheet.GetRowCount
SetCurrentRow Sets the Focus on the specified Row of the Data Table DTSheet.SetCurrentRow(RowNumber)
SetNextRow Shifts the Focus to the next Row of the Data Table. DTSheet.SetNextRow
SetPrevRow Shifts the Focus to the Previous Row of the Data Table. DTSheet.SetPrevRow

Test Your Automation Testing Skills By Taking Our Free Practice Tests On This Link

Share this post
[social_warfare]
Automation Testing Tutorial | GUI Objects
Automation Testing Tutorial | CREATING A TEST

Get industry recognized certification – Contact us

keyboard_arrow_up