Identify treeitems based on its parent node

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
ElkeV
Posts: 4
Joined: Wed Oct 28, 2020 10:02 am

Identify treeitems based on its parent node

Post by ElkeV » Thu May 27, 2021 3:43 pm

In our application (wpf) we have a tree where the treeitems are not unique by its caption. To uniquely identify them, I need to look at the caption of it's parent or maybe even it's complete path up to the root item.
Is it possible to do this using the Xpath?

I attached a screenshot and a snapshot of the tree.

I can identify for instance the treeitem 'RxZone2' using

Code: Select all

/form[@automationid='MainWindowForm']//container[@automationid='cntRegion1']//tree[@automationid='SystempointsTree']//treeitem/text[@caption='RxZone2']
but that will only give me the first of 10 occurances of this treeitem (under 'SimFire1')

To get the treeitem under 'SimFire2' I want to use something like

Code: Select all

/form[@automationid='MainWindowForm']//container[@automationid='cntRegion1']//tree[@automationid='SystempointsTree']//treeitem/text[@caption='RxZone2']/parent::treeitem/text[@caption='SimFire2']
Unfortunately that doesn't work
You do not have the required permissions to view the files attached to this post.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Identify treeitems based on its parent node

Post by odklizec » Fri May 28, 2021 6:54 am

Hi,

You were close with "parent" axis ;) What you are actually looking for, is xpath like this:

Code: Select all

/form[@automationid='MainWindowForm']//container[@automationid='cntRegion1']//tree[@automationid='SystempointsTree']//treeitem/text[@caption='SimFire2']/parent::treeitem//treeitem/text[@caption='RxZone2']
You first need to identify the "SimFire2" text element, then go back to its parent treeitem and from here you can go to nested treeitem you are looking for. Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ElkeV
Posts: 4
Joined: Wed Oct 28, 2020 10:02 am

Re: Identify treeitems based on its parent node

Post by ElkeV » Fri May 28, 2021 11:01 am

Thanks for your answer, this works.

Although it does need a lot of search time (5s) to identify a treeitem this way