Hello Ranorex,
In my test I need to handle two types of the dialog which are invoked by double clicking table rows. Table is traced in DDT loop. Based of the appeared dialog type different smart folder should be executed. I used Code Module to identify which type of dialog appears and set appropriate value for the Module variable (DialogType). Than, following smart folders has a condition based on that variable value. For better understanding please have a look at the attached screenshot ConditionalExecution.png
The issue is that DialogType variable looks changed, and SmartFolder condition ignore that value.
So what is the reason why condition is not triggered during test run?
Thanks!
Condition execution based on Parameter value
Condition execution based on Parameter value
- Attachments
-
- ConditionalExecution.png (56 KiB) Viewed 1728 times
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Condition execution based on Parameter value
Could it because you're setting the DialogType to "NewItemDialog" and testing for "NewItemType"?
Doug Vaughan
Re: Condition execution based on Parameter value
It's a mistake in text on the screenshot. Sorry for that.
DialogType variable could have value as "NewItemType" or "RequestSeriesDialog". And condition checks whether DialogType is equal to first or second value.
Thanks
DialogType variable could have value as "NewItemType" or "RequestSeriesDialog". And condition checks whether DialogType is equal to first or second value.
Thanks
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Condition execution based on Parameter value
I figured as much, but you always double check the easy stuff.
How are you binding your parameter? In the Data Binding column for Define_NewItemType_Dialog I don't see anything about variables being bound. This could be because your text just covers it or you're not using a module variable to bind the parameter.
So I'm guessing you're just setting the parameter from 005_01_Open_and_preview_all_requests directly from code rather than binding the value to a module variable and binding that module variable back to the DialogType parameter back on the rxtst page. I have no idea if this is causing your problem, but that would be the first thing I'd try.

How are you binding your parameter? In the Data Binding column for Define_NewItemType_Dialog I don't see anything about variables being bound. This could be because your text just covers it or you're not using a module variable to bind the parameter.
So I'm guessing you're just setting the parameter from 005_01_Open_and_preview_all_requests directly from code rather than binding the value to a module variable and binding that module variable back to the DialogType parameter back on the rxtst page. I have no idea if this is causing your problem, but that would be the first thing I'd try.
Doug Vaughan
Re: Condition execution based on Parameter value
I'm setting DialogType parameter in the code in Define_NewItemType_Dialog module, like this:
This module does not have any data bindings.
It seems that during run time DialogType variable do have required value, because in code i have:
and in report:
17:49:26 Info User code Dialog type is: NewItemType
Hope this info helps to understand the problem better.
Regards
Code: Select all
TestSuite.CurrentTestContainer.Parameters["DialogType"] = "NewItemType";
It seems that during run time DialogType variable do have required value, because in code i have:
Code: Select all
Report.Info("User code", "Dialog type is: " + TestSuite.CurrentTestContainer.Parameters["DialogType"]);
17:49:26 Info User code Dialog type is: NewItemType
Hope this info helps to understand the problem better.
Regards
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Condition execution based on Parameter value
It looks like Ranorex doesn't like it when you set the parameter directly. You need to user a module variable and bind that back to the parameter. See the attached solution.
Doug Vaughan
Re: Condition execution based on Parameter value
Thanks a lot for your idea. It works fine for me. And in the same time my solution uncover a bug or at least possible improvement 

Re: Condition execution based on Parameter value
I do not think this needs any improvement, and it's definitely not a bug.
The expected and recommend way to handle parameters/variables is to create module variables and bind them to parameters, as Vaughan said. Then you use that variable in your module. You should not be setting the test suite parameter directly as it may not be guaranteed to be updated or used in the way you are expecting, where using it through a local module variable will work every time.
The expected and recommend way to handle parameters/variables is to create module variables and bind them to parameters, as Vaughan said. Then you use that variable in your module. You should not be setting the test suite parameter directly as it may not be guaranteed to be updated or used in the way you are expecting, where using it through a local module variable will work every time.
Shortcuts usually aren't...
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Condition execution based on Parameter value
I do see why you'd expect it to work by setting the parameter directly. From a strictly .net standpoint, it should work. I suspect krstcs is right though simply because this functionality is ONLY used in conjunction with Ranorex Studio conditional statements. I'm fairly sure that if you set a parameter directly you can access the value in another module programmatically, or at least you could in prior versions of Ranorex.bk_tester wrote:Thanks a lot for your idea. It works fine for me. And in the same time my solution uncover a bug or at least possible improvement
On the purely pragmatic level of test design, by not using the module variable as an intermediary you're obfuscating a variable from that rxtst page which acts as an overview for the scenario. You just need to know your audience.
Doug Vaughan
Re: Condition execution based on Parameter value
Hello,
Setting a local parameter programmatically and using its value in an IF conditions works normally if you use the parameter inside of its scope (see:lesson-4-ranorex-test-suite and then “Scope of data containers”). The easiest way to demonstrate this is if we take the sent solution “HoldMyBeer” and look at the parameters “Beer” and “MoreBeer” that are defined inside of the “Six_Pack” TC. If we want to access the local parameter “Beer” and “MoreBeer” inside of the child “Mmmmmm_Beer” Smart folder we need to bind them to the module variable like “Better_Beer”.
If not, we need to access the parent parameter with the right code path, in our case we change/update the code in the “WhatToDo” code module to:
Or for example we can create a new code module in our case “SetParameterForIF”: In this module you write your “normal” code for modifying the local parameter of the “Six_pack” TC:
Best regards, Marcel
Setting a local parameter programmatically and using its value in an IF conditions works normally if you use the parameter inside of its scope (see:lesson-4-ranorex-test-suite and then “Scope of data containers”). The easiest way to demonstrate this is if we take the sent solution “HoldMyBeer” and look at the parameters “Beer” and “MoreBeer” that are defined inside of the “Six_Pack” TC. If we want to access the local parameter “Beer” and “MoreBeer” inside of the child “Mmmmmm_Beer” Smart folder we need to bind them to the module variable like “Better_Beer”.
If not, we need to access the parent parameter with the right code path, in our case we change/update the code in the “WhatToDo” code module to:
// TestSuite.CurrentTestContainer.Parameters["Beer"] = "Good Beer"; TestSuite.CurrentTestContainer.ParentContainer.Parameters["Beer"] = "Good Beer";So we are setting the value of the “Six_Pack” TC parameter to “Beer”.
Or for example we can create a new code module in our case “SetParameterForIF”: In this module you write your “normal” code for modifying the local parameter of the “Six_pack” TC:
TestSuite.CurrentTestContainer.Parameters["Beer"] = "Good Beer";and then the IF condition should work as expected.
Best regards, Marcel
- Attachments
-
- HoldMyBeerUpdated.zip
- (3.24 MiB) Downloaded 50 times
-
- Posts: 254
- Joined: Tue Mar 24, 2015 5:05 pm
- Location: Des Moines, Iowa, USA
Re: Condition execution based on Parameter value
great explanation. Thanks!Marcel wrote:wisdom dropped here...
Doug Vaughan
Re: Condition execution based on Parameter value
The problem with that logic is that is assumes that it will always be that way. You can't make that assumption. You should be using local (module) variables, bound to parameters or data columns, not setting them directly. The back-end of many of the objects that Ranorex exposes are not guaranteed to be static for any length of time and they can change on any given release.
Shortcuts usually aren't...