Numerical comparison

Best practices, code snippets for common functionality, examples, and guidelines.
dan
Posts: 2
Joined: Wed Mar 02, 2016 10:45 am

Numerical comparison

Post by dan » Wed Feb 07, 2018 7:27 am

I encounter a problem and need your help
For the values in text box validation, I want to compare the value, but not string.
Take the text box below for example








What I expected: 1.00 and 1.0000 are considered as successful
Actual: 1.00 are considered as failed

Thanks in advance!
You do not have the required permissions to view the files attached to this post.

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

Re: Numerical comparison

Post by odklizec » Wed Feb 07, 2018 9:45 am

Hi,

I'm afraid, this kind of comparison/validation is not possible without using code. You would have to convert the string values into numbers and then compare them using for example using CompareTo method. Eventually, it may be possible to use Validate action, but instead of "AttributeEqual" you should try "AttributeRegex" and some kind of regex pattern, which would ignore redundant/missing decimal numbers. But I still think that using CompareTo is better way of comparing numbers? ;)
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

dan
Posts: 2
Joined: Wed Mar 02, 2016 10:45 am

Re: Numerical comparison

Post by dan » Thu Feb 08, 2018 3:32 am

Hi,

Thanks for your help. I will try those two methods then