HP QTP Data Table Methods

HP Quick Test Professional Data Table Methods


They are number of QTP Data Table methods to create Data Driven Framework ,below are the details.

1. Add Sheet
2. Delete Sheet
3. GetSheetCount
4. GetRowCount
5. GetSheet
6. Value
7. SetCurretRow
8. SetNextRow
9. SetPrevRow
10.Import /Import Sheet
11.Export /Export Sheet



Please find the details below

Add Sheet:

This method is used add new sheet to the run time data table
Syntax: DataTable.AddSheet("Sheet Name")

Delete:

This method is used to Delete one sheet using this method
Syntax: DataTable.DeleteSheet("Sheet Name")
Example : DataTable.DeleteSheet("Test_Cases")

GetSheetCount:

This method is used to Count number of sheets in Run time Data Table.
Syntax: DataTable.GetSheetCount

GetRowCount:

This method is used to count number of rows in the first excel sheet of the run time data table.
Syntax: DataTable.GetRowCount

GetSheet:

This method is used to get specified excel sheet from run time data table.
Syntax: DataTable.GetSheet("Sheet Name") or DataTable.GetSheet("SheetID")

Example : 
Sheet 1- 1
Sheet 2 - 2

DataTable.GetSheet(1)

Value:

This method is used to set or get value of cell data in specified the current row of the run time data table.
To Get Data
Syntax:

Variable Name = DataTable.Value(Parameter_Name,Sheet Name) or

Variable Name = DataTable(Parameter_Name,Sheet Name)

To Set Data
Syntax: DataTable.Value(Parameter Name,SheetName) = Value/Variable

DataTable(ParameterName,SheetName) = Value/Variable

Ex:
Uname = DataTable.Value("Username","rajeshk")
Pwd = DataTable.Value("Password","xxxxxxxxxx")

Browser("Gmail Login").Page("Gmail Login").WebEdit("Username").Set Uname
Browser("Gmail Login").Page("Gmail Login").WebEdit("Password").Set Pwd

SetCurrentRow:

This method is used to set specified row as current row in the run time data table.
Syntax: DataTable.SetCurrentRow(RowNumber)
Ex: Username = "Rajesh"
DataTable.SetCurrentRow(3)
DataTable.Value(3) = Username

SetNextRow:

This method is used to set the row after the current row as New Row in the Run time DataTable.
Syntax: DataTable.SetNextRow

SetPrevRow:

This method is used to set specified row as before the current row as new current row in Run time data table.
Syntax: DataTable.SetPrevRow

Import:

This method is used to import Excel file -Number of sheets to the run time Data table.
Syntax: DataTable.Import "Path of the Excel file"
DataTable.Import "E:\Automation\HP QTP\Testing.xls"

ImportSheet

This method is used to import specified excel sheet into Run time data table.
Syntax: DataTable.ImportSheet "Path of Excel file","Source Sheet","Destination Sheet"

Example:
DataTable.AddSheet "Test_Cases_App"

DataTable.ImportSheet "E:\Automation\HP QTP\Testing.xls","Test_Cases","Test_Cases_App"

Export:

This method is used Export Excel file in to specified location from another location
Syntax: DataTable.Export "Path of Excel file"

Export Sheet:

This method is used to export specified sheet into specified location
Syntax: DataTable.ExportSheet "Path of File","Sheet Name/Source Sheet"

DataTable.ExportSheet "E:\Automation\HP QTP","AutomationTesting.xls"

No comments:

Post a Comment