Pass test parameters into Ranorex data connectors?

Ask general questions here.
krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Pass test parameters into Ranorex data connectors?

Post by krstcs » Thu Oct 10, 2013 1:55 pm

Is there a way to pass test parameters into the data connectors in order to filter the connector results, especially for the SQL connector?

I use SQL Server with stored procedures which are all parameterized and I need to be able to pass in test parameters in order to have the procedure return the correct information.

For example, I have a Customer table that is the data source for my outer test case. I need to use the customer email address to look up the CustomerOrders for that customer in my test database. The customer email needs to be passed into either the stored procedure or a query in the connector in order to get the right information.

Currently I'm using custom data retrieval modules that I pass the test parameters into. It would be great if I could just pass a test parameter into the data connector and use that parameter to filter the results.
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Pass test parameters into Ranorex data connectors?

Post by Support Team » Fri Oct 11, 2013 1:40 pm

Hello,

Unfortunately, it's not possible to pass parameters to a data connector directly.
The following code snippet would modify the query for the data connector and use a variable.
Please note that you would need to call it before you load the data.
string username = "Markus";		
IList<DataCache> dataCons = TestSuite.Current.DataConnectorCaches;
foreach (var dc in dataCons)
{
	SqlDataConnector sqlDc = dc.Connector as SqlDataConnector;
	sqlDc.Query = "SELECT dbo.names.[First name] FROM dbo.names WHERE dbo.names.[First name] ='" + username + "';";		
}
Regards,
Markus (T)
.
Image

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass test parameters into Ranorex data connectors?

Post by krstcs » Fri Oct 11, 2013 1:52 pm

Thanks Markus.

Yes, I'm already doing something like that, but it gets cumbersome with anything that is complex, data-wise.



1. Can we add a Feature Request for passing test parameters to the data connectors for filtering?



2. Another, similar, Feature Request: I would also love to see the data connectors become reusable objects like recording modules or repository objects. Maybe have a data repository or make them files (.rxdat) that contain the connector info? I find myself reusing my connector information all the time and it would be nice to be able to reuse the actual connector. Either of these might also allow us to pass test parameters?
A repository could have parent branches for each type of connector and fields for the specific information, including data parameters. We could then have the data repository at the bottom of the rxtst view, like the object repository is for a rxrec view.
A file type system could just be another type of code module like rxrec that we could have user-code for defining the query and passing in parameters. Not sure how this would be passed into the test suite, but you guys are really smart... :D


Thanks!
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Pass test parameters into Ranorex data connectors?

Post by Support Team » Tue Oct 15, 2013 1:28 pm

Hello,

Thank you for your feature request.
We currently working on a way to use parameters in data connectors.

Please provide us your User Case with an example why you want to use data connectors to become reusable objects. Do you want to have multiple Test Suites or Projects that use the same data connector?

Thank you in advance.

Regards,
Markus (T)
.
Image

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass test parameters into Ranorex data connectors?

Post by krstcs » Tue Oct 15, 2013 1:42 pm

Yes, that is exactly my issue, I want to be able to reuse data connectors in multiple projects (usually under the same solution).

I use SQL Server Express for my data set, but it is dynamic at runtime. I read the data from the DB (through parameterized stored procedures (SP) in custom code) into a simple data connector at runtime, so I have to create special simple data connectors for each suite's instances of that stored procedure. So, if I have to use that SP in several suites, I have to create the simple data connector all three times, exactly the same.

I tried using a SP with no parameters in SQL Data connectors, filling in the parameters at runtime. But, as noted in http://www.ranorex.com/forum/performanc ... 64-15.html, any interaction with any object in the test suite causes Ranorex to re-query every data connector, which makes this unusable.

But, if the data connectors were modular then I would not have to re-create them in every test suite each time I needed them.

I'm going to be at the San Francisco training Thursday and Friday, I can talk to Martin (I'm assuming he's doing the training) and show him my issues if that would help?

Thanks Markus!
Shortcuts usually aren't...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Pass test parameters into Ranorex data connectors?

Post by Support Team » Wed Oct 16, 2013 4:34 pm

Hello,

Thank you for your reply.

We will provide a fix for the performance issue with SQL and Excel connectors mentioned in your last post as soon as possible. Our new version should be released next week.
Would it be an option for you to fill in these parameters at runtime if this performance issue has been fixed?

Thank you for explaining your Use Case.
It should not be necessary to show your issue to Roland at Ranorex Workshop.

Regards,
Markus (T)
.
Image

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Pass test parameters into Ranorex data connectors?

Post by krstcs » Wed Oct 16, 2013 5:01 pm

Yes, I would be able to move to a SQL connector that I would still fill at run-time, once the performance issues is fixed.

Thanks!
Shortcuts usually aren't...

delfindevassy
Posts: 4
Joined: Tue Aug 27, 2013 12:26 am

Re: Pass test parameters into Ranorex data connectors?

Post by delfindevassy » Wed Oct 16, 2013 7:16 pm

Hi krstcs,

I see that you are using SQL server as data source.
Are you adding each variable as a column in the database table? If you don't mind, can you please share a little details?