SetCurrentRow Method In QTP

Data Driven Testing is the most important aspect within the framework of the Automation Testing.
Some methods have a lot of relevance when we concentrate on the automation of a module using this very technique.


Sets the specified row as the current (active) row in the run-time Data Table.
Important Information
  • You can set a row only if it contains at least one value.
  • If you call another action (local or external) after performing this method, then when you return to the current action after the called action is complete, the current row in the action sheet is reset to the row corresponding to the current iteration (regardless of the value previously set in the DataTable.SetCurrentRow step.)
Syntax
DataTable.SetCurrentRow(RowNumber)


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)
The example below performs the equivalent of renaming a column (parameter) in the DataTable by copying the data from one column to a new column with a new name, and then deleting the old column.
'add a new column
DataTable.GetSheet("dtGlobalSheet").AddParameter "NewColumn","Row1Value"

'copy the cells from the old column into the new column
cnt=DataTable.GetRowCount
For i=1 to cnt
       DataTable.SetCurrentRow(i)
       OldVal=DataTable.Value("OldColumn","dtGlobalSheet")
       DataTable.Value("NewColumn","dtGlobalSheet")=OldVal
Next

'delete the old column
DataTable.GetSheet("dtGlobalSheet").DeleteParameter("OldColumn")


Post a Comment

Previous Post Next Post