The Data Table is a Microsoft Excel sheet with columns and rows representing the data
The Data Table contains one Global tab plus an additional tab for each action.
The Data Table assists you in parameterizing your test.
To view the Data Table, click the Data Table toolbar button
Data Table Parameters:
Data Table parameters enable you to create a data-driven test, component, or action that runs several times using the data you supply. In each iteration, QTP uses a different value from the Data Table
Setting Data Table Parameter Options:
Data Table parameters enable you to create a data-driven test (or action) that runs several times using the data you supply. For each iteration, QTP uses a different value from the Data Table.
When Data Table is selected as the parameter type, the Parameter Options dialog box enables you to configure your parameter to use values from the Data Table.
The Global sheet contains the data that replaces parameters in each iteration of the test. If you create a Global parameter called Arrivals, the Global sheet might look like this: Run Time Data Table:
During the run session, QTP creates a run-time Data Table associated with your test.It displays the run-time data in the Data Table pane so that any changes to the Data Table can be seen as they occur.The final data from the run-time Data Table is displayed in the Run-Time Data Table in the Test Results window
The Run-Time Data Table displays the parameterized values that were used, as well as any output values stored in the Data Table during the run.The Run-Time Data Table can be viewed from the Test results window.
Run Time Data Table Methods:
AddSheet Method
DeleteSheet Method
Export Method
ExportSheet Method
GetCurrentRow Method
GetRowCount Method
GetSheet Method
GetSheetCount Method
Import Method
ImportSheet Method
SetCurrentRow Method
SetNextRow Method
SetPrevRow Method
AddSheet Method
Adds the specified sheet to the run-time Data Table and returns the sheet so that properties can be directly set for the new sheet in the same statement.
Syntax:
DataTable.AddSheet(SheetName)
Example
Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00")
DeleteSheet Method
Deletes the specified sheet from the run-time Data Table.
Syntax
DataTable.DeleteSheet SheetID
The SheetID can be the sheet name or index. Index values begin with 1.
Example
DataTable.DeleteSheet "MySheet"
MySheet gets deleted from Data Table
Export Method
Saves a copy of the run-time Data Table in the specified location
Syntax
DataTable.Export(FileName)
Example:
DataTable.Export ("C:\flights.xls")
ExportSheet Method
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:
DataTable.ExportSheet "C:\name.xls" ,1
GetCurrentRowCount
Returns the current (active) row in the first sheet in the run-time Data Table
Syntax:
DataTable.GetCurrentRow
Example
row = DataTable.GetCurrentRow
Reporter.ReportEvent 1, "Row Number", row
GetRowCount Method
Returns the total number of rows in the longest column in the first sheet in the run-time Data Table
Syntax
DataTable.GetRowCount
Example:
rowcount = DataTable.GetSheet("MySheet").GetRowCount
Reporter.ReportEvent 2, "There are " &rowcount, "rows in the data sheet."
GetSheet Method
Returns the specified sheet from the run-time Data Table
Syntax
DataTable.GetSheet(SheetID)
Example
MyParam=DataTable.GetSheet ("MySheet").AddParameter("Time", "8:00")
GetSheetCount Method
Returns the total number of sheets in the run-time Data Table
Syntax
DataTable.GetSheetCount
Example
Sheetcount = DataTable.GetSheetCount
Import Method
Imports the specified Microsoft Excel file to the run-time Data Table.
Syntax
DataTable.Import(FileName)
Example
DataTable.Import ("C:\flights.xls")
ImportSheet Method
Imports a sheet of a specified file to a specified sheet in the run-time Data Table.
The data in the imported sheet replaces the data in the destination sheet
Syntax
DataTable.ImportSheet(FileName, SheetSource, SheetDest)
Example:
DataTable.ImportSheet "C:\name.xls" ,1 ,"name"
SetCurrentRow Method
Sets the specified row as the current (active) row in the run-time Data Table.
Syntax
DataTable.SetCurrentRow(RowNumber)
Example
DataTable.SetCurrentRow (2)
SetNextRow Method
Sets the row after the current (active) row as the new current row in the run-time Data Table.
Syntax
DataTable.SetNextRow
Example
DataTable.SetNextRow
SetPreRow Method
Sets the row above the current (active) row as the new current (active) row in the run-time Data Table.
Syntax
DataTable.SetPrevRow
Example
DataTable.SetPrevRow
Data Table Properties
GlobalSheetProperties
RawValueProperties
LocalSheetProperties
GlobalSheet Properties
Returns the first sheet in the run-time Data Table
Syntax
DataTable.GlobalSheet
Example
ParamValue=DataTable.GlobalSheet.AddParameter("Time", "5:45")
LocalSheet Properties
Returns the current (active) local sheet of the run-time Data Table.
Syntax:
DataTable.LocalSheet
Example
MyParam=DataTable.LocalSheet.AddParameter("Time", "5:45")
RawValue Property
Retrieves the raw value of the cell in the specified parameter and the current row of the run-time Data Table
Syntax
DataTable.RawValue ParameterID [, SheetID]
Example
FormulaVal=DataTable.RawValue ("Date","ActionA")
Value Property
This is a DataTable’s default property. It retrieves or sets the value of the cell in the specified parameter and the current row of the run-time Data Table
Syntax
DataTable.Value(ParameterID[,SheetID]) = NewValue
Example
DataTable.Value(“Destination”,”ActionA”) = “New York”
Name Property
Returns the name of the run-time data sheet
Syntax
DTSheet.Name
Example
SheetName = DataTable.LocalSheet.Name
No comments:
Post a Comment