Hi,
We are using CSV test data file and binding some columns to boolean test variables.
But this binding throws run time exception when the cell is empty.
Exception:
Failed to set value '' to variable 'ExecuteDynamic'.
String was not recognized as a valid Boolean.
at Ranorex.Core.Data.ReflectionDataProvider.SetValue(CaseInsensitiveString variableName, String value, Boolean exceptionOnFail) at Ranorex.Core.Data.ReflectionDataProvider.SetValue(CaseInsensitiveString variableName, String value) at Ranorex.Core.Testing.TestSuiteModule.RunInternal(DataContext parentDataContext)
Test variable declaration:
bool myExecuteDynamic = false;
[TestVariable("0B935733-C432-47AF-A7F0-F7F9AC6445E6")]
public bool ExecuteDynamic
{
get { return myExecuteDynamic; }
set { myExecuteDynamic = value;}
}
Let me know if there is any way to achieve this.
Bind empty cells in a CSV file to bool Test variable.
-
- Posts: 24
- Joined: Thu Feb 06, 2014 10:57 am
Bind empty cells in a CSV file to bool Test variable.
- Attachments
-
- EmptyBooleanVariable.jpg (75.49 KiB) Viewed 2052 times
Re: Bind empty cells in a CSV file to bool Test variable.
Ranorex stores and passes ALL values as strings, so the values "true" and "false" are strings and will not work in conditional statements. In order to use the "true" and "false" values as a boolean you need to convert them.
You will probably need to do this in user code.
You will probably need to do this in user code.
Code: Select all
bool myBool = bool.Parse("true");
string boolAsString = "false";
bool stringAsBool = bool.Parse(boolAsString);
Shortcuts usually aren't...