Implementing multiple conditions on attribute Values

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 36
Joined: Mon Jan 16, 2017 3:24 pm

Implementing multiple conditions on attribute Values

Post by manalitatke » Thu Sep 14, 2017 7:59 pm


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?


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

Re: Implementing multiple conditions on attribute Values

Post by krstcs » Thu Sep 14, 2017 8:56 pm

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

Posts: 254
Joined: Tue Mar 24, 2015 5:05 pm
Location: Des Moines, Iowa, USA

Re: Implementing multiple conditions on attribute Values

Post by Vaughan.Douglas » Mon Sep 18, 2017 5:03 pm

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.
Doug Vaughan