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

Ask general questions here.
praneet
Posts: 26
Joined: Thu Nov 08, 2018 2:22 am

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

Post by praneet » Fri Feb 22, 2019 12:35 pm

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

manish
Posts: 47
Joined: Fri Aug 10, 2018 12:46 pm

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

Post by manish » Fri Feb 22, 2019 1:12 pm

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5331
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

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

Post by odklizec » Fri Feb 22, 2019 1:34 pm

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
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration