SQL data source and Simple data table together

Best practices, code snippets for common functionality, examples, and guidelines.
theraviz
Posts: 75
Joined: Sun Apr 14, 2019 9:46 am

SQL data source and Simple data table together

Post by theraviz » Mon Oct 05, 2020 9:17 am

HI,

I have a scenario where I have to use 2 Data tables in 1 test case.

1 data table is an SQL data source and another one is a Simple Ranorex table.

Scenario :

I have to enter the marks of the students in one application.

Student Name needs to be fetched from SQL DB and Marks from Excel.

On the first iteration Student Name from first row of SQL must be taken along with the first row marks from the simple ranorex data table.

On the second iteration Student Name from second row of SQL must be taken along with the second row marks from the simple ranorex data table.

and it goes on like this.

How is this possible?

When I tried with smart folder it takes first row student name first and iterates through full row of marks table then takes the second student name and again iterates through all mark rows.

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

Re: SQL data source and Simple data table together

Post by odklizec » Mon Oct 05, 2020 9:48 am

Hi,

I'm afraid, this task could be achieved only programmatically. You will simply have to add a code module right before the smart folder with second data connector (the one with marks). In this code module, you need to obtain the actual data connector (names) iteration number and then limit data range of second data connector (marks) with with actual iteration number.
Here you can find the code for obtaining actual iteration number:
viewtopic.php?f=16&t=10027&p=50579&#p47879
And here you can find a sample code to change the data connector range:
looping-module-in-a-test-case-t10499.html#p42114
Now you simply have to combine these two pieces in one code ;)
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