Page 1 of 1

Data Binding - Data Variables not using the default value

Posted: Fri Aug 16, 2019 1:26 am
by gmaroli
Hi,
Using Ranorex 9.1
I have setup a CSV dataConnector to my test case
Also did the Data Binding for the module.
in the Module --> Manage Data Sources, I have setup a default value

in my input CSV file if I do not pass any value to this variable, then I was expecting the Default value is picked
But this does not happen, the variable is blank.
How can I set this up, so that if the value in the CSV file for this variable is not passed, then I need to pick up the default value

Re: Data Binding - Data Variables not using the default value

Posted: Fri Aug 16, 2019 8:57 pm
by Support Team
Hi gmaroli,

A variable's default value is only used when running a module outside of a test suite or the variable is not bound to anything. As a best practice, it is recommended to add the desired value in the data connector so it is used as the variable value. This is the simplest (and in most scenarios, often best) method.

If this is really needed, alternatively, we can use some code to detect if the variable empty, and if so, set it to a different "default" value. The below example will change the variable varTest to defaultValue (set in the recording module).

Code: Select all

public void checkVariable(string defaultValue)
{
	if (varTest == string.Empty)
		varTest = defaultValue;
}
1.png

I hope this helps!

Cheers,
Ned

Re: Data Binding - Data Variables not using the default value

Posted: Mon Aug 19, 2019 1:49 am
by gmaroli
Thanks . This information is useful