Relay16 webui has the same xpaths for verifying some of the elements on the page

@robert.james just to summarize the thread so far:

It seems like you are trying to test images rendered in your anvil app via Selenium.
You want to use the xpath to determine whether they are the correct image
But you have noticed that the xpath for images might be duplicated.

@owen.campbell has suggested scrapping xpaths and refer to element ids instead.
There is a linked post that shows how to add an id to an anvil component.
And there is a link to documentation on how to use selenium to locate elements by id.

There is also some confusion about “adding a component”.
You have already added your image components.
You either dragged these into the designer or added them in code.

Hopefully that’s a good summary of where we are.

If you want to persist down the xpath route then you might want to use the absolute xpath.
This is more brittle, as mentioned in selenium documentation, but at least they are guaranteed to be different.

If you want to try the solution with element ids, then you’ll need to add ids to your Image components - see above. (No need to mention xpaths if you’re trying this method - just pick different ids per component you need to refer to).

Let us know what you’ve tried and where you’re stuck.

4 Likes