how to click xpath with dynamic id?

Hey, i started learning about automation lately and im kind of stuck i don’t know how to click this element
xpath=//div[@id=‘this is dynamic’]/div[2]/ul/li[8]/a
there are many xpath of this kind in the page with different id and i would like to detect them and be able to click using an index
thanks

If the whole id is dynamic, then you cannot use it at all, as it will only work the one time. Look for either another attribute that is stable/static or a neighbouring stable element, or text, from which you can start and “jump” to the dynamic one and create a pathway using the xpath functions, like: following, preceding, parent et al.
If only part of the id is dynamic, then you might be able to, as long as the part creates an unique pathway. There is the xpath function, contains, that would allow you to use the stable / static part and not the whole. You can allow us to assist but we would need to see the HTML.
As well, you might be able to use some part of the <a> tag’s hypertext to spot on to the final element you want.

1 Like