Datatable assists in parameterizing the Tests.
'Add a Sheet in QTP At RunTime
Syntax: DataTable.AddSheet(SheetName)
Example
DataTable.AddSheet("SampleSheet")
'Delete a Sheet in QTP At RunTime
Syntax: DataTable.DeleteSheet SheetName or SheetId
Example
DataTable.DeleteSheet "SampleSheet"
DataTable.DeleteSheet 2
'Exports contents of Run-time Datatable to an excel
sheet.
DataTable.Export(FileName)
DataTable.Export("C:\FLIGHTS.XLS")
'Exports a specified sheet of Run-Time DataTable
DataTable.ExportSheet(FileName, SheetName)
DataTable.ExportSheet("C:\FLIGHTS.XLS",1)
'Gets the current row from Run-Time DataTable
CurrentRow = DataTable.GetCurrentRow
msgbox CurrentRow
'Total Number of Rows in Run-Time DataTable
RowCount = DataTable.GetSheet(SheetName).GetRowCount
'Total Number of Sheets in Run-Time DataTable
DataTable.GetSheetCount
'Importing values from an Excel sheet to Run-Time DataTable
DataTable.Import ("C:\flights.xls")
'Importing values from a particular excel Sheet to Run-Time DataTable
DataTable.ImportSheet(FileName, SheetSource, SheetDest)
'Sets specified row as the current row in the Run-Time DataTable
DataTable.SetCurrentRow(RowNumber)
'Sets the row after the current row as the new current row in the Run-Time DataTable
DataTable.SetNextRow
'Sets the row above the current as the new current row in the Run-Time DataTable
DataTable.SetPrevRow
'Retrieves or Sets the value of the cell in the specified parameter and the current row of the run-time DataTable
Syntax:
To get the value:
DataTable.Value (ParameterID, SheetID)
(OR)
DataTable(ParameterID, SheetID)
To set the value:
DataTable.Value (ParameterID, SheetID)=New Value
(or)
DataTable(ParaterID[, SheetID]) = NewValue
Example:
DataTable(2,3) = "UserName2"
Table of Contents
- QTP Introduction
- Manual Testing Disadvantages
- Advantages of QTP
- Add-In Manager in QTP
- Testing Process in QTP
- Components of QTP
- Recording QTP Scripts
- Recording Modes
- QTP Script View
- Object Identification
- Object Repository
- Object Spy
- Actions in QTP
- Checkpoints
- Parameterizing
- Working with Data Table
- Environment Variables
- Virtual Objects
- Output Values
- Running QTP Test Scripts
- Recovery Scenario
- Sample Scripts
- Certification Questions
Tuesday, September 7, 2010
Working with DataTable
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment