Data Binding - Data Variables not using the default value

Ask general questions here.
gmaroli
Posts: 5
Joined: Wed May 22, 2019 2:25 am

Data Binding - Data Variables not using the default value

Post by gmaroli » Fri Aug 16, 2019 1:26 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12002
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Fri Aug 16, 2019 8:57 pm

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
1.png (10.01 KiB) Viewed 122 times

I hope this helps!

Cheers,
Ned
.
Image

gmaroli
Posts: 5
Joined: Wed May 22, 2019 2:25 am

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

Post by gmaroli » Mon Aug 19, 2019 1:49 am

Thanks . This information is useful