How to access the column names of the test data files

Best practices, code snippets for common functionality, examples, and guidelines.
yuanqu
Posts: 1
Joined: Mon May 04, 2015 6:37 pm

How to access the column names of the test data files

Post by yuanqu » Mon May 04, 2015 6:54 pm

This is related to data driven test.

After added an excel data. I would like to cycle through the columns in the data table and extract the column name.

How do I do this?

Thanks!

AFI
Posts: 13
Joined: Tue Feb 24, 2015 8:36 am
Location: Germany

Re: How to access the column names of the test data files

Post by AFI » Tue May 05, 2015 9:08 am

Try this:

Code: Select all

Ranorex.Core.Testing.ITestCase itc = Ranorex.Core.Testing.TestCase.Current;
Ranorex.Core.Data.ColumnCollection columnc = itc.DataContext.Parent.CurrentRow.Owner.Columns;
foreach(Ranorex.Core.Data.Column col in columnc){
	Report.Info(col.Index + " " + col.Name);
}