Wednesday 16 September 2015

DATA TABLE METHODS IN QTP


DataTable Method
GetRowCount:

Description :
Returns the total number of rows in the longest column in the first sheet in the run-time Data Table (global sheet).

Syntax
DataTable.GetRowCount

Return Value : Number

Example :
The following example uses the GetRowCount method to find the total number of rows in the longest column of the MySheet run-time data sheet and writes it to the report.
rowcount = DataTable.GetSheet("MySheet").GetRowCount
Reporter.ReportEvent 2, "There are " &rowcount, "rows in the data sheet."


-------------------------------------------------------------------------------------------------
SetNextRow:

Description:
Sets the row after the current (active) row as the new current row in the run-time Data Table.

Note: You can only set a row that contains at least one value. If the current row is the last row in the Data Table, applying this method sets the first row in the Data Table as the new current row.

Syntax :
DataTable.SetNextRow

Example :
The following example uses the SetNextRow method to change the active row to the next row in the run-time Data Table.
DataTable.SetNextRow
SetCurrentRow:
 
Description :
Sets the specified row as the current (active) row in the run-time Data Table.
Note: You can only set a row that contains at least one value.

Syntax :`
DataTable.SetCurrentRow(RowNumber)

Argument
Type
Description
RowNumber
Number
Indicates the number of the row to set as the active row. The first row is numbered 1.
 
Example
The following example uses the SetCurrentRow method to change the active row to the second row in the global run-time Data Table.
DataTable.SetCurrentRow (2)

GetSheet:
 
Description :
Returns the total number of sheets in the run-time Data Table.

Syntax :
DataTable.GetSheetCount

Return Value : Number
Example :
The following example uses the GetSheetCount method to find the total number of sheets in the run-time Data Table and writes it to the report.
sheetcount = DataTable.GetSheetCount
Reporter.ReportEvent 0, "Sheet number", "There are " & sheetcount & " sheets in the Data Table."
-------------------------------------------------------------------------------------------------
GetParameterCounts:
 
Description :
Returns the total number of parameters (columns) in the run-time Data Table sheet.
Syntax : DTSheet.GetParameterCount
http://akhilreddytechnologies.blogspot.in/2015/07/qtp-real-time-very-imp-scripts-for.html

Return Value :Number
Example
The following example uses the GetParameterCount method to find the total number of parameters (columns) in the run-time Data Table sheet (MySheet) and writes it to the report.
paramcount = DataTable.GetSheet("MySheet").GetParameterCount
Reporter.ReportEvent 2, "There are " &paramcount, "columns in the data sheet."
-------------------------------------------------------------------------------------------------

AddSheet:

Description :
Adds the specified sheet to the run-time Data Table and returns the sheet so that you can directly set properties of the new sheet in the same statement.
Syntax :
DataTable.AddSheet(SheetName)

Argument
Type
Description
SheetName
String
Assigns a name to the new sheet.
Return Value : DTSheet Object.
 
Example :
The following example uses the AddSheet method to create the new sheet, "MySheet" in the run-time Data Table and then adds a parameter to the new sheet.
Variable=DataTable.AddSheet ("MySheet").AddParameter("Time", "8:00")
-------------------------------------------------------------------------------------------------
DeleteSheet:

Description :
Deletes the specified sheet from the run-time Data Table.
Syntax :
DataTable.DeleteSheet SheetID

Argument
Type
Description
SheetID
Variant
Identifies the sheet to be returned. The SheetID can be the sheet name or index. Index values begin with 1.
Example
The following example uses the DeleteSheet method to delete the sheet, "MySheet" from the run-time Data Table.
DataTable.DeleteSheet "MySheet"
-------------------------------------------------------------------------------------------------http://akhilreddytechnologies.blogspot.in/2015/07/qtp-real-time-very-imp-scripts-for.html





GetSheetCount:

Description : Returns the total number of sheets in the run-time Data Table.
Syntax :  DataTable.GetSheetCount
Return Value : Number
Example
The following example uses the GetSheetCount method to find the total number of sheets in the run-time Data Table and writes it to the report.
sheetcount = DataTable.GetSheetCount
Reporter.ReportEvent 0, "Sheet number", "There are " & sheetcount & " sheets in the Data Table."
AddParameter:

Description :
Adds the specified parameter (column) to the sheet in the run-time Data Table, sets the value of the first row to the specified value, and returns the parameter so that you can directly set or retrieve properties of the new parameter in the same statement.
Syntax : DTSheet.AddParameter(ParameterName, Value)

Argument
Type
Description
ParamterName
String
Assigns a name to the new parameter. If another parameter in the sheet has the same name, a number (i.e. '1') will be appended to the assigned ParameterName. If the ParameterName contains illegal characters, the illegal characters will be replaced with '_' characters.
Value
String
Assigns a value to the first row of the parameter.
 
Return Value :DTParameter Object
Examplehttp://akhilreddytechnologies.blogspot.in/2015/07/qtp-real-time-very-imp-scripts-for.html

The following example uses the AddParameter method to create the new Parameter, "Arrival" within the new sheet, MySheet of the run-time Data Table, and sets the first cell in the column as "New York". Because the method also returns the newly created parameter, it is possible to use methods or check properties of the new sheet within the same statement.

ParamName=DataTable.AddSheet("MySheet").AddParameter("Arrival", "New York").Name

Note that if a parameter with the name "Arrival" already exists in the sheet, the example above will return "Arrival1" as the actual name assigned to the new parameter.


Subscribe  channel to get  latest video


No comments:

Post a Comment