Page 1 of 1

Create repo item of parent element based on child attribute

Posted: Fri Nov 23, 2018 1:14 pm
by semate
Is it possible to select a item in the repository based on an attribute of the child element? For example to select the element of the 'dataGroup' container item which is the parent of the Text item with the Caption "Thumbnails" (see below)
RepoImg.PNG
I tried:

Code: Select all

toolbar[@id='buttonBarViewMode']//text[@caption='Thumbnail']/../../../element
which gave me back an element, but the wrong one (=always the same, no matter what caption is set to)

Code: Select all

toolbar[@id='buttonBarViewMode']//element/..//text[@caption='Thumbnail']
which gave me back the text element (child)

Thanks!

P.S.: I do know how to solve it in C# and sure, I could use the different element names - but that's not the point.

Re: Create repo item of parent element based on child attribute

Posted: Fri Nov 23, 2018 1:25 pm
by odklizec
Hi,

It may be possible to solve your problem with xpath relationship operators. But it's hard to say without seeing, at very least, Ranorex snapshot of the UI. Could you please post the snapshot (NOT screenshot) of the problematic toolbar?

From the screenshot, I can only guess that the xpath you are looking for should look like this:

Code: Select all

toolbar[@id='buttonBarViewMode']//text[@caption='Thumbnails']/ancestor::container[@class='dataGroup']