Few More on Datatable...

AddParameter
Adds a column to the sheet in the run-time Data Table, and sets the value of the first row.

GetParameter
Retrieves the specified parameter from the run-time Data Table sheet.

DeleteParamater
To delete a parameter from a sheet in datatable

Any changes made using these methods will effect the run-time DataTable only which can be seen on the test results window at the end of running the test. These changes will not effect the Design time datatable. These can be retrieved and used in the script too.

Example

' Create a column header UserName and password and sets the first value as CNR and prokarma

DataTable.GlobalSheet.AddParameter "UserName", "CNR"
DataTable.GlobalSheet.AddParameter "Password", "prokarma"

'Picking up the value from UserName and save it in val1, val2 to use it further

'Here the row pointer will be pointing to the first row in the datatable and will be picking up the values existing there.



val1=DataTable.GetSheet("dtGlobalSheet").GetParameter ("UserName")
val2=DataTable.GetSheet(1).GetParameter("Password")
MsgBox Val1 & " " & Val2

Datatable.SetNextRow ' Second row

'The row pointer will be pointing to the next row in the datatable and will be picking up the values existing there.

val3=DataTable.GetSheet(1).GetParameter ("UserName")
val4=DataTable.GetSheet("dtGlobalSheet").GetParameter("Password")
MsgBox Val3 & " " & Val4

' We can as well put the values back into the datatable

Datatable.SetNextRow ' Third row
Datatable("userName",1)="pranav"
Datatable("Password",1)="newpwd"
val5=DataTable.GetSheet(1).GetParameter ("userName").Name
val6=DataTable.GetSheet(1).GetParameter("Password")
MsgBox val5 & " " & val6

We can even create a new sheet into the data table and add few values in it

DataTable.AddSheet("MySheet").AddParameter("AccountNumber","047845")

The parameter from the MySheet can also be deleted.

DataTable.GetSheet("MySheet").DeleteParameter("AccountNumber")

No comments: