Datatable in QTP

Datatable is one of the parameterization techniques in QTP. It is a kind of excel sheet with rows and columns which displays a data applicable to the application under test.There are two kinds of data sheet one is Global sheet and other is local sheet.

 

To see data table Option
Click on view ->Data Table.

Go through the below sample code to understand the methods and properties of datatable.

call Datatable.Addsheet(“QEworks”)  ‘To add a new sheet in data table

call Datatable.Deletesheet(“QEworks”) ‘ To delete a specific sheet from datatable

call Datatable.Addsheet(“QEworks”)

call Datatable.exportsheet(“C:\My Documents\Qeworks\Export.xls”,”QEworks”) ‘To Export run time data from datatable to external sheet

msgbox Datatable.GetCurrentRow ‘Returns a row content on selected row

msgbox Datatable.GetRowCount ‘Returns a count of rows in table

msgbox Datatable.GetSheetCount ‘Returns a count of total number of sheet

Datatable.import(“C:\Qeworks\Import.xls”) ‘import a whole xls document into datatable

Datatable.importsheet(“C:\Qeworks\Import.xls”,”Action”) ‘Import only specified sheet

Datatable.setcurrentRow(4) ‘To set row selection pointer at particular row

Datatable.setnextRow ‘ To move row selection pointer at Next row

Datatable.setPrevRow  ‘ To move row selection pointer at Previous row

msgbox Datatable.Rowvalue(“username”1)

call Datatable.getSheet(“Global”).Addparameter(“Password”,”QEAdmin123″)

msgbox Datatable.getSheet(2).GetRowCount

Datatable.addsheet(“DT”)

msgbox Datatable(“Date”,”DT”)

Datatable(“Date”,”DT”)=”4521″

msgbox Datatable(“Date”,”DT”)

Above are the some of the methods in data table.

Comments (0)
Add Comment