Page 1 of 1

Google Chrome Element Paths Keep Changing

Posted: Mon Aug 13, 2018 5:10 pm
by rphmee
Has anyone else come across this issue?

Elements in Chrome will work for a while, but at some point their path suddenly changes and they can no longer be found. This happens for basic elements in Chrome like the search bar. For some elements I currently have up to 4 different repo elements all with different paths. I'm assuming this shouldn't be happening, since that would make tests with chrome useless, so what am I doing wrong? I have the Chrome extension for ranorex installed and active. Ranorex version is 8.1.1.

Re: Google Chrome Element Paths Keep Changing

Posted: Mon Aug 13, 2018 8:42 pm
by sstowe
(I am not Ranorex support, just a member of the community. So I may be full of balogna.)

In many web apps, the run time XPath is determined run time. When you record or examine an item in spy, you are seeing it as a point in time. I have an element whose XPath when I spied it was:

div/div[2]/div[2]/div[2]/div/button[1]/span

But at run time, the bolded div could be in different positions. In MY case, removing that div index allowed Ranorex to find the element consistently. I did not bother to examine if this was the fastest possible element identification, but it was stable.

This information won't answer your question directly, but is great for gaining overall understanding the Ranorex XPath. If you want to post the different XPaths you have for your element, I might have some insight.

Cheers.

Re: Google Chrome Element Paths Keep Changing

Posted: Mon Aug 13, 2018 9:33 pm
by Support Team
Hi rphmee,

Like sstowe mentions, there could be a dynamic element or attribute in your application that changes frequently, therefore breaking the current RxPath. Ranorex tries to avoid using dynamic attributes by default but there is no way for it to know what is dynamic automatically in every application. There are a few ways to work around dynamic attributes/elements, but the easiest is usually just removing it and replacing with an "Any-Child" // or "Any-Optional" /?/.

Bad: Form/DynamicElement/button
Good: Form/?/button -or- Form//button

If you are able to provide the three different RxPaths you have, and a Ranorex Snapshot file of the problematic element, I will be more than happy to help you build a better RxPath. Also, we have a great blog post on this topic I recommend checking out if dynamic attributes are a frequent issue throughout your application.

I hope this helps!

Cheers,
Ned