Wednesday, March 20, 2013

About Data Table



Data Table
Data table is used to parameterize your test. It is having two sheets. Global and Action. Global sheet is used across all the action. Action sheet is used for particular action. Two type of data table. Design time and Run time data table.  Design time data table is associated with test before and after the test execution. Run time data table is associate with test during test execution. Data table is stored under Test name > Data table folder.
Data table object method


AddSheet:-Adds the specified sheet to the run-time Data Table and it returns the sheet so that we can add properties to the sheet in the same statement.
datatable.addsheet("sheetname") 



Addparameter- adds parameter or property to sheet
datatable.addsheet("sheetname").Addparameter(Col_Value,Value)



deletesheet
This method will delete a specific sheet from the data table during run time.
datatable.DeleteSheet sheetName



Export :-Saves the copy of the run-time datable in the specified location
datatable.Export ("location along with Excel name") 
Note :- if the file is not created /present QTP will create the file at runtime and exports the specified sheet.



ExportSheet :- exports the specific sheet in the run-time datatable to An Excel file .
DataTable.ExportSheet "location along filename", "sourcesheet" 
Note:
1.       if the file is not present or created QTP will create the file at runtime and exports the specified sheet.
2.       If the excel file is already created but there is no sheet associated with it. QTP will open this file and add the sheet.
3.       Say if the file is already created and the sheet is already there, QTP will overwrite the sheets



Import :- imports the specified Excel file to the run time Data Table
DataTable.import(location+filename) 
Import method deletes/replaces all table available in datatable during run with its sheets.Remember sheet1 will be copied to Global,Sheet2 will be copied to Action. If you have more sheets in the source excel there will no Excel tab in QTP.So we need to create those tab by addSheet then only we will be able to get those extra sheets else those data is not accessable using this method.

It is a best practice to know the numbers of sheets presents in the source file and try to add those sheets during runtime.Then try to get those sheets in QTP



Import Sheet :- To import the specific sheet in the run time data table.The data in the imported sheet replaces the data in the destination sheet
DataTable.ImportSheet ("location+filename", "Source sheet",destination sheet)



GetCurrentRow :- returns the current row in the first sheet in the run-time Data-Table(Global sheet)
var x = DataTable.getCurrentRow  



GetSheetCount:-returns the total number of sheets in the run-time Data Table
Var x = datatable.getsheetcount 



GetSheet :-returns the specifed sheet from run-time Data Table
DataTable.GetSheet("abc")



GetRowCount :-Returns the total number of rows in the longest column in the first sheet in the run-time sheet in the data table(Global sheet)
DataTable.GetSheet("abc").getRowCount



SetCurrentRow :-set the specified row as the current(active) row in the run-time Data Table
DataTable.SetCurrentRow(value)



SetNextRow:-Set the row after the current(active) row as the new current row in the run-time Data-Table
DataTable.GetSheet("abc").setNextRow 


setPrevRow:-set the row above the current(active) row as the new current(active)row in the run-time Data Table
DataTable.SetPrevRow

No comments:

Post a Comment