Page 1 of 1

Rxpath issues with custom tag names

Posted: Tue Sep 07, 2021 12:19 pm
by mrt
Dear folks,

I have an issue since day 1 using Ranorex and it becomes more and more painful:

If I use tagnames in the Rxpath that are - let's say "standard HTML" - like body or label, object recognition works fine.

Code: Select all

/body/label/...
But if I try to use "custom" tagnames which were defined by developers (and are almost everywhere), this does not work.
I have to add tag and tagname attribute, like this:

Code: Select all

tag[@tagname='mytag1']/tag[@tagname='mytag2']/...
As you see, this easily doubles the characters for each element and is much more complicated.
Not only creating those repository items take longer and longer, because of the long RXpath it is also very hard to maintain them.

Is there any possibility to get around this, maybe by adding some list of tagnames somewhere so that they are recognized as easily as standard HTML tags?

Help would be greatly appreciated, thanks!

Re: Rxpath issues with custom tag names

Posted: Tue Sep 07, 2021 12:50 pm
by odklizec
Hi,

I'm afraid, there is no any workaround for this. However, are you sure you must add all these elements to the xpahts? In most cases, it should be enough to use only few elements with good identification attributes. Also a very good practice is to use rooted folders, containing the general xpath common for multiple elements. Eventually, use other elements as "anchors" and traverse to the element you want using xpath axes (parent, ancestor, descendant, etc...).

Re: Rxpath issues with custom tag names

Posted: Tue Sep 07, 2021 1:02 pm
by mrt
Hi,

ok, sad to hear.
Basically the whole hierarchy of the page consists of one custom tag after another, so I am afraid there is no way getting "around them".

Yes, I already have several rooted folders in place to get things organized, otherwise the pain would be even higher.

Thanks!

Re: Rxpath issues with custom tag names

Posted: Tue Sep 07, 2021 1:09 pm
by odklizec
Rooted folders not only make the things better organized, but they also make the search for elements faster! Well, good luck with custom elements. I understand your pain, but I personally don't care about custom tags or "standard" HTML tags as long as there are unique and persistent attributes ;) In many cases, I'm forced to use classes, which are often full of texts. But they are also pain to use because one needs to use regexes to pick only the useful details and eliminate all redundant strings. And this makes the xpaths even more complicated ;)