Thursday, 1 December 2011

Data Table

      Data Table
---------------------------------------------

It is  nothing but a type of excel  sheet with columns and rows which shows the data in the data table related to the test. This helps in parameterizing the test.

    Data Table Object Model
----------------------------------------------
    
 Data Table      :    Represents the global and all local sheets
 Dtsheet          :    Represent single sheet in test
 Dtparameter  :    Represents single column in the sheet.


    Types of data tables 
----------------------------------------------
  
 Design time      :     It is Created before the test is run.
 Run time          :     It is generated after execution of test.

    Types of sheets in data table
-----------------------------------------------

Global Sheet : It is used for storing the data used for Test Iteration .If there are more number of action in a test, then use of global sheet will be better and easier to pass the values and which is visible to all the actions
             
Local Sheet : It is used for storing the data related to corresponding Action iteration. Here actions run only one iteration.In local Sheet it is relevant to only particular action which is used .It is visible to its respective action.


   Parameterization of Data table
-------------------------------------------------
 The first thing to know is, How  to retrieve data from Data table

 - - To retrieve data from Local Sheet :-

DataTable("ColumnName", dtLocalSheet)

 - - To retrieve data from Global Sheet :-

DataTable("ColumnName", dtGlobalSheet)

 - - To retrieve the data from one action to another action :-

DataTable.GetSheet("Action  Name").GetParameter("Column Name").ValueByRow(Row number from where the data to be taken)

    Import and Export Method in DataTable
-------------------------------------------------------------
Methods for Import and Export of Data table From a .xls file

--   Import method : This method is used to import an entire workbook into QTP data table.
             
Ex:  datatable.Import "Give the relative path where the xls file is stored in system"

datatable.Import "\\Filename.xls"

 --  Export method : This method is used to export the entire data tables from QTP to an .xls file.
               
Ex:  datatable.Export "Give the relative path where the xls file is stored in system"              

datatable.export "\\Filename.xls"

 --   ImportSheet method : This method is used to import only a specific sheet into QTP datatable.
               
 Ex :  datatable.ImportSheet "Give the relative path where the xls file is stored in system",1,2

[ (1)Imports the source sheet and  (2) to destination sheet] 
          
 datatable.ImportSheet "\\Filename.xls",1,2

 --   ExportSheet method : This method is used to export only a specific datatable sheet from QTP to an .xls file.
              
Ex :  datatable.ExportSheet "Give the relative path where the xls file is stored in system",1

[  Exports the specified sheet to a file; Overwrites by default, only one copy is exported. ] 
             
datatable.ExportSheet "\\Filename.xls",1

No comments:

Post a Comment