Page 1 of 1

OR condition in XPath

Posted: Thu Dec 19, 2019 12:01 pm
by prasoon.jmit
Hi,

Can I use OR condition in XPAth?

Re: OR condition in XPath

Posted: Thu Dec 19, 2019 12:14 pm
by odklizec
Hi,

Yes, you can use conditions in Ranorex xpaths. For example like this:

Code: Select all

element//container/button[@accessiblename='Close' or @accessiblename='' and @accessiblerole='PushButton' and @visible='true']

Re: OR condition in XPath

Posted: Fri Jan 12, 2024 1:24 pm
by mrt
How is the combine logic for which condition (and, or) is evaluated first?
Usually one would control this by using brackets, but they are automatically removed from RxPath.

These are not the same:

Code: Select all

A or B and X

Code: Select all

(A or B) and X

Code: Select all

A or (B and X)
thanks!

Re: OR condition in XPath

Posted: Mon Jan 22, 2024 8:36 am
by melodican
Interesting question! Would also like to hear an answer from Ranorex.

Re: OR condition in XPath

Posted: Fri Jan 26, 2024 9:30 am
by mrt
Hello,
the support told me it is evaluated from left to right (so 1st attribute together with 2nd, then the result together with 3rd and so on.)

I do not know what I did wrong before,
but now I can enter round brackets in the RxPath to group and/or clauses as needed like:

Code: Select all

//tag[@id='5' or (@tagname='abc' and @label='asdf')]

Re: OR condition in XPath

Posted: Mon Feb 12, 2024 9:26 am
by Marie143
odklizec wrote:
Thu Dec 19, 2019 12:14 pm
Hi,
drywall contractor services drywall services quotes
Yes, you can use conditions in Ranorex xpaths. For example like this:

Code: Select all

element//container/button[@accessiblename='Close' or @accessiblename='' and @accessiblerole='PushButton' and @visible='true']
thanks for the info,