Page 1 of 1

Setting Datasource Range From and To parameters from code

Posted: Tue Jul 30, 2013 8:51 pm
by mzperix
Hi,

we are using excel to generate data. Usually when we test, we only want to use one row each time. So in the Data Source dialog we set the Data Range From and To parameters to play only one row.

After each run, we need to set these parameters manually to the next row.

My question is: is there a way to reach programmatically these From and To paramters?

Regards,
Zoltan

Re: Setting Datasource Range From and To parameters from code

Posted: Wed Jul 31, 2013 4:05 pm
by Support Team
Hi,

There will be the possibility (with the next Ranorex version) to define the data range via a command line argument.
Would this be an option for you?

Regards,
Markus

Re: Setting Datasource Range From and To parameters from code

Posted: Thu Aug 01, 2013 1:20 pm
by odklizec
Hi Markus,

Nice to hear there will be an option to set the data range via the command line argument! However, I think it would be nice to have also an "official" coded way ;)

Some time ago I was in a similar problem like Zoltan and I solved it by code like this...
var CurrentTestCase = TestSuite.Current.GetTestCase("TestCaseName");	
CurrentTestCase.DataRange.MinRange = 0;
CurrentTestCase.DataRange.MaxRange = 9;	
//setting the TestCaseName data range using items 1-10
CurrentTestCase.DataContext.SetRange(CurrentTestCase.DataRange.MinRange,CurrentTestCase.DataRange.MaxRange);
Report.Log(ReportLevel.Info, "Setting Data Range", "TestCaseName range:" + "\nMin: " + CurrentTestCase.DataRange.MinRange.ToString() + "\nMax: " + CurrentTestCase.DataRange.MaxRange.ToString());
There are two downsides of this solution. I was informed that using internal API methods is not supported and recommended. And additionally, the test execution progress bar is not correctly updated with new data range (as I reported here).

Re: Setting Datasource Range From and To parameters from code

Posted: Tue Aug 06, 2013 3:35 pm
by Support Team
Hi,

Thanks for posting the code :)!
The methods you are using "MinRange, MaxRange, and SetRange" are documented methods so they can be used "officially" ;).

Regards,
Markus

Re: Setting Datasource Range From and To parameters from code

Posted: Wed Aug 07, 2013 9:19 am
by odklizec
Hi Markus,

Thanks for the clarification! So if the used methods are official, could we please have fixed the problem with not updated data range values (which I reported here)? ;) Thank you in advance!

Re: Setting Datasource Range From and To parameters from code

Posted: Thu Aug 08, 2013 10:56 am
by mzperix
Thank you!

Looks like my problems will be solved :D

Hope the bug will be fixed in future versions too!

Regards,
zoltan

Re: Setting Datasource Range From and To parameters from code

Posted: Thu Aug 08, 2013 11:52 am
by Support Team
Hi,

The issue with the not updated data range was already forwarded.
There should be a fix in a future Ranorex version.

Regards,
Markus

Re: Setting Datasource Range From and To parameters from code

Posted: Thu Aug 08, 2013 2:30 pm
by odklizec
Thanks for the info Markus! That's a great news!

Re: Setting Datasource Range From and To parameters from code

Posted: Fri Sep 20, 2013 3:13 am
by caleb
Posting because I ended up here looking for this command line argument and then discovered it was available in the 4.1 release after checking the dates on the previous posts.

As per the command line help

testcasedatarange|tcdr:<name or guid of test case>=<data range>
Sets the data range for a testcase.
A very useful feature, thanks very much