Setting Datasource Range From and To parameters from code

Class library usage, coding and language questions.
mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Setting Datasource Range From and To parameters from code

Post by mzperix » Tue Jul 30, 2013 8:51 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Setting Datasource Range From and To parameters from code

Post by Support Team » Wed Jul 31, 2013 4:05 pm

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

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

Re: Setting Datasource Range From and To parameters from code

Post by odklizec » Thu Aug 01, 2013 1:20 pm

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).
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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Setting Datasource Range From and To parameters from code

Post by Support Team » Tue Aug 06, 2013 3:35 pm

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

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

Re: Setting Datasource Range From and To parameters from code

Post by odklizec » Wed Aug 07, 2013 9:19 am

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!
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

mzperix
Posts: 137
Joined: Fri Apr 06, 2012 12:19 pm

Re: Setting Datasource Range From and To parameters from code

Post by mzperix » Thu Aug 08, 2013 10:56 am

Thank you!

Looks like my problems will be solved :D

Hope the bug will be fixed in future versions too!

Regards,
zoltan

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Setting Datasource Range From and To parameters from code

Post by Support Team » Thu Aug 08, 2013 11:52 am

Hi,

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

Regards,
Markus

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

Re: Setting Datasource Range From and To parameters from code

Post by odklizec » Thu Aug 08, 2013 2:30 pm

Thanks for the info Markus! That's a great news!
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

caleb
Posts: 24
Joined: Mon Jul 08, 2013 3:35 am

Re: Setting Datasource Range From and To parameters from code

Post by caleb » Fri Sep 20, 2013 3:13 am

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