How to ignore Case sensitivity in validations

Ask general questions here.
User avatar
sandamal
Posts: 28
Joined: Wed Jul 08, 2015 7:50 am

How to ignore Case sensitivity in validations

Post by sandamal » Fri Jan 13, 2017 10:09 am

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

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to ignore Case sensitivity in validations

Post by odklizec » Fri Jan 13, 2017 10:38 am

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
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

krstcs
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to ignore Case sensitivity in validations

Post by krstcs » Fri Jan 13, 2017 2:57 pm

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());
Shortcuts usually aren't...

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to ignore Case sensitivity in validations

Post by odklizec » Fri Jan 13, 2017 3:01 pm

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! ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration