How to automate an id that is different everytime

Hi, I have searched more in the last two days, then I think I have every searched before. I want to automate something that has a different id all the time. Anyone got any suggestions for a resolution for this. I was thinking I might have to go down the excel route but its not something I wanted to do. This is the snippet and the ID changes all the time depending on which selection I pick. but the rest stays static. I could automate it and then manually put the ID I want in, but thats not what I want to do. Any help greatefully received.


You just don’t rely on the id="something".

    <a class="btn btn-primary actio selectDeparture" href="#ds">xxxxx</a>

You want to igore id="2" in the <a>.
You have to find some way to identify this <a> uniquely.
How can you ?

I guess, the text body xxxxx is something unique; no other <a> has the text content xxxxx.

If that is the case, the following XPath will select the <a> tag.


There could be many alternative XPath or CSS Selector to use. It totally depends how the HTML of your target web page is coded. Read your HTML thoroughly and find the locator.

Thank you for this. I will try it and see where it takes me :slight_smile: .