Page 1 of 1

UserCode to get data from associated data source based on header name

Posted: Fri Feb 22, 2019 12:35 pm
by praneet
Hi,

I have alrady associated sample dat source to the test case. I want to
get the columns into the user code
Please provide the user code

Re: UserCode to get data from associated data source based on header name

Posted: Fri Feb 22, 2019 1:12 pm
by manish
Hi,

For this you can create variables that you can use to bind to the data columns in your data source. Such a variable will take the data for the bound column on every iteration of the data source.
You do not need any complex code in your code module to get it done.

Thanks
Manish

Re: UserCode to get data from associated data source based on header name

Posted: Fri Feb 22, 2019 1:34 pm
by odklizec
Hi,

Just in case Manish's suggestion is not what you are looking for, here is the code to obtain value from actual data connector row and given column name:
var curTC = TestSuite.CurrentTestContainer; //current TestCase/SmartFolder
//var curTC = TestSuite.Current.GetTestContainer("ContainerName"); //ContainerName = TestCase/SmartFolder name
valFromCurRowAndGivenColumn = curTC.DataContext.CurrentRow.Values[curTC.DataContext.Source.Columns["ColumnName"].Index]; //returns value from current data connector row and given column