Condition based on data source?

Ask general questions here.
mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Condition based on data source?

Post by mrt » Thu Aug 13, 2020 10:27 am

Hello,

i have cascaded Smart folders with different data sources, like this:

Code: Select all

Test Suite
    SmartFolder1 (datasource1)
        SmartFolder2 (datasource2)
I want to set a IF condition for SmartFolder2, to compare to a attribute of datasource1.

So the IF statement should look like:

If column2 from datasource2 is equal column2 of datasource1


I could possibly use an extra recording, in which datasource1 is read to a variable, bind that to a global variable and use this variable in the IF condition, but this seems unnecessary complicated to me.

Is there a simple solution for that?

thank you!

mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Re: Condition based on data source?

Post by mrt » Mon Aug 24, 2020 11:04 am

Hmm...
I tried using a previous extra recording, which gets the value from the UI into a module variable, and the module variable has a data binding to a global variable.
But when I insert that global variable using standard dollar notation ($variable) into the smart folder condition field, it does not work, it always skipps all iterations.

I couldn't find any solution online to use a variable inside the condition.
There are several threads, like this one:
https://www.ranorex.com/forum/how-to-se ... 11378.html
where the title would fit exactly to what I want to achieve.
But when looking at it, it is again just a hardcoded text inside the IF-condition.

Any ideas?

thank you!

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

Re: Condition based on data source?

Post by odklizec » Mon Aug 24, 2020 2:23 pm

Hi,

As far as I know, TC/SF conditions does not accept variables, so entering variable will not help you. It's just parsed as a string ;) Could you please post a screenshot of your test suite structure and screenshot of the conditions and parameters view?
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

mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Re: Condition based on data source?

Post by mrt » Tue Aug 25, 2020 8:50 am

Thank you for the reply.

Oh, sad - I was begging that the use of variables is possible...

Sure, I tried to create a quick demo project illustrating my issue:

I use projects, and tasks.

I have a CSV file for all projects ccontaining all project attributes (about 50 attributes).
I have separate CSVs for each task type (about 150 attributes).

So my test structure looks like this:
2020-08-25 09_43_16 -Window.png
2020-08-25 09_43_16 -Window.png (13.54 KiB) Viewed 105 times

The "parent-level" data source iterates through all projects.
2020-08-25 09_44_01 -Window.png
2020-08-25 09_44_01 -Window.png (24.57 KiB) Viewed 105 times

The "child-level" data sources iterate through the different task types.
2020-08-25 09_46_46 -Window.png
2020-08-25 09_46_46 -Window.png (26.81 KiB) Viewed 105 times

These screenshots show the previous configuration, where I had the project ID in all data sources and a double condition on each of the child folders, one to match the project ID in parent data source, and one to match it in child data source.
But I want to get rid of the hardcoded projectIDs, they should only be in ONE csv (data_project.csv) for maintainability, that way they have to be changed only in one place and not 4.

So the idea is, remove the ProjectID from all child data sources, and set the child-conditions to match the task type, which is currently processed by the parent data source.

Without variable, i can only hardcode this for every type, where i end up like this for 3 different project types:
Last edited by mrt on Tue Aug 25, 2020 9:02 am, edited 1 time in total.

mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Re: Condition based on data source?

Post by mrt » Tue Aug 25, 2020 8:58 am

for some reason I can't add more than 3 attachments -anyway:

so I end up like this, by copying the same testcase 3 times for 3 different project types, which does not look good and is very redundant:
2020-08-25 09_49_54 -Window.png
2020-08-25 09_49_54 -Window.png (32.49 KiB) Viewed 104 times
In future, the type number will grow up to 10 and the task type number will grow up to 10-15.

So instead of having ONE testcase with 10-15 subfolders, i will end up with 10 testcases which all contain the same, only the condition is different - that is unnecessarily complicated.

Conditions for the latter case:
2020-08-25 09_54_57 -Window.png
2020-08-25 09_54_57 -Window.png (29.45 KiB) Viewed 104 times
2020-08-25 09_55_30 -Window.png
2020-08-25 09_55_30 -Window.png (41.04 KiB) Viewed 104 times

mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Re: Condition based on data source?

Post by mrt » Tue Aug 25, 2020 9:01 am

So my solution would be, to save the current parent iteration to a variable, and use the variable in the child condition like:
2020-08-25 09_57_56 -Window.png
2020-08-25 09_57_56 -Window.png (9.57 KiB) Viewed 103 times
I hope I could make it clear what I want to achieve and where i am stuck. :D
Thank you for help!

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

Re: Condition based on data source?

Post by odklizec » Tue Aug 25, 2020 11:50 am

Hi,

Well, I think that in this particular case, it would much better to use coded approach? ;) TC/SF conditions are currently pretty simple and not suitable for more complicated scenarios. Please check my post here, where you can find an example code, which shows how to evaluate a data connector value and based of the actual value, either enable or disable TC/SF of your choice...
https://www.ranorex.com/forum/stop-runn ... tml#p45267
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

mrt
Posts: 36
Joined: Mon Mar 16, 2020 11:31 am

Re: Condition based on data source?

Post by mrt » Thu Aug 27, 2020 8:34 am

Alright thanks, I will have a look at it. :)

BR