lopp within loop within loop

Best practices, code snippets for common functionality, examples, and guidelines.
sroell-X
Posts: 2
Joined: Mon Jun 22, 2020 7:44 am

lopp within loop within loop

Post by sroell-X » Tue Sep 21, 2021 2:59 pm

Hello Ranorexers,

what i need to to:
iterate over a list of countries, for each contries iterate over a list of dates abd for each date iterate over a list of codes.
We use recording modules, because we are no no C# or VB programmers.
Behaviour should be that:
- pick first country from list of countries
- pick first date fromlist of dates
- for that date iterate list of codes (verify error codes do not exist on web site)
- if that is done pick next date for first country and iterate lost of codes, and so on
- when last date is done, start with second country and first date and iterate over error codes list.

My questions: can this be done with Ranorex Studio without writing user code?
If so, what is the best way, the best practise to do so? We want to avoid a cartesian product and make sure that each unique combination of country and date doess iterated only once through list of codes and ensure that combination "CD" of country C and date D ist only used once.

Many thanks in advance for hints if this is possible and if so, how.

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

Re: lopp within loop within loop

Post by odklizec » Mon Sep 27, 2021 7:32 am

Hi,

From your description, it seems to be doable by nested SmartFolders.
SmartFolder_A - list of countries
|_SmartFolder_B - list of dates
|_SmartFolder_C - list of codes

This structure will pick the first country from the list of countries, then pick the first date and finally, loop the list of codes.
Once the list of codes is looped, it will go back to the list of dates, select next one and again loop the list of codes. And this will be repeated, until the List of dates is finished.
And finally, it will go back to the list of countries, select second one and again loop the List of dates and codes as before.

However, if you need also different list of dates/codes for each country, you may need to implement multiple smartfolders with conditions! And this may make the structure of smartfolders extremely difficult to maintain ;)
SmartFolder_A - list of countries
|_SmartFolder_B - list of dates
|_SmartFolder_C_1 - list of codes for USA - condition: use this list, only if current country is USA
|_SmartFolder_C_2 - list of codes for Canada - condition: use this list, only if current country is Canada
|_SmartFolder_C_3 - list of codes for Germany - condition: use this list, only if current country is Germany
|_...

Hope this helps?
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

sroell-X
Posts: 2
Joined: Mon Jun 22, 2020 7:44 am

Re: lopp within loop within loop

Post by sroell-X » Sun Oct 24, 2021 3:18 pm

Many thanks for the reply.

I tried nested smart folders before posting the post above, it got a kind of "cartesian product".

You wrote "condition: use this list, only if current country is Canada".
How can i set a condidtion on iterating / not iterating a list?

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

Re: lopp within loop within loop

Post by odklizec » Mon Oct 25, 2021 7:06 am

Hi,

The SmartFoder/TestCase conditions only control if the SF/TC should be processed or not. In other words. If the condition is met, SF/TC is processed (including data connector loop), otherwise, it's not.
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