Google Chrome Element Paths Keep Changing

Ask general questions here.
rphmee
Posts: 6
Joined: Tue Jun 05, 2018 2:46 pm

Google Chrome Element Paths Keep Changing

Post by rphmee » Mon Aug 13, 2018 5:10 pm

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.

sstowe
Posts: 62
Joined: Thu May 31, 2018 2:26 pm

Re: Google Chrome Element Paths Keep Changing

Post by sstowe » Mon Aug 13, 2018 8:42 pm

(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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Google Chrome Element Paths Keep Changing

Post by Support Team » Mon Aug 13, 2018 9:33 pm

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