Tracking elements by unique identifier

Ask general questions here.
mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Tracking elements by unique identifier

Post by mander95 » Tue Mar 07, 2017 5:17 pm

Is it possible to track elements on a specific webpage by a specific attribute regardless of the type of elements it is? For example, I want to find an object on a webpage that I am making an automation for by it's innertext and click it. So the function would search through the elements on the page for an element that matches this specific innertext and click it and have the function be type ambiguous ( on one webpage, the innertext could match for an atag but on another page, the innertext could match an litag). Does such a function exist in Ranorex?

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

Re: Tracking elements by unique identifier

Post by krstcs » Tue Mar 07, 2017 5:43 pm

Use the webelement type in your XPath instead of the actual type:

Code: Select all

//webelement[@innertext='MyInnerText']
Note, however, that this will require Ranorex to search the ENTIRE PAGE until it finds the right element, so it may take a while and can cause your scripts to fail due to timeouts finding the elements.

So, this is not usually recommended.
Shortcuts usually aren't...

mander95
Posts: 66
Joined: Tue Jun 21, 2016 7:35 pm

Re: Tracking elements by unique identifier

Post by mander95 » Wed Mar 22, 2017 5:48 pm

My project works now, thank you very much!