Page 1 of 1

Implementing multiple conditions on attribute Values

Posted: Thu Sep 14, 2017 7:59 pm
by manalitatke
Hello,


I want to set my attribute value of inner text for a repository item to a variable.
I am setting the default value of the variable, and my inner text is able to retrieve and compare against this default variable.

However, i want to implement a logic wherein i can have two conditions:

[@innertext>=$defaultvalue and @innertext <= defaultValue+0.5]

However, i am not able to add the other half.

Is there any way apart from User code logic wherein i can directly implement this logic via edit path for inner text attribute.


Basically, is it possible to have a condition for implementing range values for inner text attribute for a repository item?


Thanks.

Re: Implementing multiple conditions on attribute Values

Posted: Thu Sep 14, 2017 8:56 pm
by krstcs
All variables are considered to be strings when used in the XPath, so you cannot use mathematical constructs. You can use the '+' as a string concatenation operator, but not for math.

If you want to do math you will need to do the calculations for the new value in user code and then set the variable to that new value.

Note: You can also use the "OR" operator in the XPath, but Ranorex will no longer allow you to use the XPath editor because OR is a complex mechanism while AND is a simple mechanism.

Re: Implementing multiple conditions on attribute Values

Posted: Mon Sep 18, 2017 5:03 pm
by Vaughan.Douglas
If you happen to be using Excel as a data source (and assuming you're pulling defaultvalue from it), you can get Excel to do the calculation for you. I've used this method to calculate things like current date or current date +/- number of days.

Out side of that, you're going to be digging into code.