Page 1 of 1

How to ignore Case sensitivity in validations

Posted: Fri Jan 13, 2017 10:09 am
by sandamal
Hi Im constantly troubled with failings on Case sensitivity validations like below. :x

does not match the specified value (actual='Active', expected='ACTIVE').

is there a setting to Ignore case sensitivity in test suit level . :roll:

Please advice

Re: How to ignore Case sensitivity in validations

Posted: Fri Jan 13, 2017 10:38 am
by odklizec
Hi,

I'm afraid, there is no solution at the test suite level. What you can do is to add a case insensitive regex to the problematic validations. Instead of AttributeEqual use AttributeRegEx. Unfortunately, Validate action with AttributeRegEx currently cannot be combined with variable (directly in Recording action). So you will have to convert the Validation action to "user code" first, and then modify the converted action with above suggested regex. It should look like this:

Code: Select all

Validate.Attribute(repo.YourItemInfo, "InnerText", new Regex("(?i:" + stringVariable + ")\\s*$"));
And the same you can do with repo xpaths:

Code: Select all

.//td[@innertext~'(?i:yourtext)\s*$']
or combined with variable...

Code: Select all

.//td[@innertext~'(?i:'+$stringVariable+')\s*$']
BTW, you can cast your vote about combining regexes with variables (in validate actions) here:
http://uservoice.ranorex.com/forums/150 ... on-match-v

Re: How to ignore Case sensitivity in validations

Posted: Fri Jan 13, 2017 2:57 pm
by krstcs
First, if the case is important and your SUT says "Active" then your test should test for "Active" not "ACTIVE". These are different, and sometimes it is a requirement to test for the exact case.

Second, if you don't care about case you can always just change the case of both actual and expected values to the same case like:

Code: Select all

Validate.Equal(actual.ToUpper(), expected.ToUpper());

Re: How to ignore Case sensitivity in validations

Posted: Fri Jan 13, 2017 3:01 pm
by odklizec
krstcs wrote:Second, if you don't care about case you can always just change the case of both actual and expected values to the same case like:

Code: Select all

Validate.Equal(actual.ToUpper(), expected.ToUpper());
Nice tip Kelly! ;)