Page 1 of 1

Finding controls by their children's properties

Posted: Thu Mar 23, 2017 5:39 pm
by tmcpherson
I'm attempting to write some xpath to efficiently find a dom control. The dom itself doesn't have unique properties, but one of the child elements does. I have the following xpath that finds it correctly:

/dom[@domain='stuff']//?[@tagname='candidate-home']//ancestor-or-self::dom

However, I remember seeing some syntax to shorten this. I don't remember exactly what the syntax was, but it looked something like

/dom[@domain='stuff' and ?[@tagname='candidate-home']]

Is that actually a thing, or am I completely making this up? I've tried that syntax (and similar) but ranorex spy doesn't like it.

Re: Finding controls by their children's properties

Posted: Thu Mar 23, 2017 7:15 pm
by krstcs
That's not a thing in Ranorex. Ranorex uses a subset of the full XPath spec.

In Ranorex, you need to use the "ancestor-or-self::<element-type>" or "parent::<element-type>" notation.