Manually Read Next using Excel Data Connector

Ask general questions here.
rgervais
Posts: 3
Joined: Wed Aug 12, 2015 3:15 pm

Manually Read Next using Excel Data Connector

Post by rgervais » Wed Sep 02, 2015 4:29 pm

Morning,

Is there any way to force the current position in an Excel file to the next row when using the Excel Data Connector? Say with a C# user code or something?

We are looking a some test examples which would be better suited on two excel rows.

Thanks in advance.

Bob

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

Re: Manually Read Next using Excel Data Connector

Post by odklizec » Fri Sep 04, 2015 7:38 am

Hi Bob and welcome here,

Could you please be more specific about what exactly you want to achieve?

If I understand you right, you have a data connector connected to TestCase and you want in one iteration actually use two rows from the attached data connector? But what would you want to do in next iteration? Skip that second row (already used in previous iteration) and continue with third row?

While it may be possible to use multiple rows within the same iteration (via some clever code), I think it's not a very good idea to mix multiple data connector rows in one iteration, because it will cause a mess and your tests will be hard to maintain and understand. Maybe if you describe in more details your application and test scenario you want to automate, we can find a better solution of your problem?

I personally have some scenarios, which use the same data connector, but with dynamically assigned range of rows to nested Test Cases. So for example during the first iteration of parent TC, I'm setting range 1-5 to child TC, and during second iteration of parent TC, I'm setting range 6-10 to child TC. But the code behind this is relative simple and so easy to understand. I'm never mixing multiple rows during the same iteration.
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

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

Re: Manually Read Next using Excel Data Connector

Post by krstcs » Fri Sep 04, 2015 1:52 pm

One row = one test scenario. You should not use multiple rows at the same time from the same data source. I would highly recommend re-thinking your data/test strategy to make sure you only use one row at a time instead of trying to work around the way Ranorex does things. You're making a lot more work for yourself.


Barring that, you can instead use a database and nest your test cases in a way that allows you to make database calls based on what you need at runtime. This is what I do and it works much better than flat files when you have any kind of complex data structure. Test cases are just for-each loops that iterate over each row of the data set, so if you nest them you have other for loops inside.

In code the test suite would look something like this:

Code: Select all

foreach(DataRow r in testDataConnector1) {
  //run modules here - these modules can only see testDataConnector1
  
  foreach(DataRow r in testDataConnector2) {
    //run modules here - these modules can see both data connectors
  }
  
  //run modules here - these modules can only see testDataConnector1
}
But, as Pavel said, it would be helpful if you could tell us exactly what you want to do with this setup so we can tell you if there is a better way given the way Ranorex works.
Shortcuts usually aren't...

rgervais
Posts: 3
Joined: Wed Aug 12, 2015 3:15 pm

Re: Manually Read Next using Excel Data Connector

Post by rgervais » Fri Sep 04, 2015 3:46 pm

Thanks Pavel & Krstcs

I have a test case that has a number of recordings, in which 5 can possibly repeat 5 times, and another 6 can also repeat 5 times.

So lets say I have an auto insurance policy with up to 5 vehicles, and up to 5 drivers per vehicle. So the Vehicle "input" contains 5 screens/recordings, and the driver "input" contains 6 screens/recordings. Each of these screens contains a number of data elements from the spreadsheet.

I was hoping to use these recordings in a loop, and use the existing data bindings rather than have multiple versions of them. (vehMake, vehModel...vehMake_1, vehModel1, etc)

I just starting out with Ranorex, so suggestions for alternative processing are appreciated.

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

Re: Manually Read Next using Excel Data Connector

Post by Support Team » Thu Sep 10, 2015 9:35 am

Hi Bob,

Unfortunately I'm not exactly sure if I got your intention correctly.
May I ask you to upload a sample test suite of your current status and a short description what you want to achieve?

PS: If you don't want to upload a sample to the public forum you can send it also to [email protected]

Thank you.

Regards,
Markus (S)

rgervais
Posts: 3
Joined: Wed Aug 12, 2015 3:15 pm

Re: Manually Read Next using Excel Data Connector

Post by rgervais » Thu Sep 10, 2015 3:00 pm

I got around this by manually setting the vars, and calling the recordings.

I created a recording with all the required vars bound from a single row in a spreadsheet. To simplify, we can have up to 5 occurrences of the column Name. Name_1, Name_2, etc. For each of these vars, I check to make sure I have a value, if so, I set the recording2 variable value. recording2.Name = Name_1, then I call recording2.

This allows me to loop over the five occurrences using only a single set of variables for the recording. Works quite well.