TestProject Forum
Powered by leading experts in the test automation community

Find element with changing id in the html code

I’m writing selenium code for an app where the element’s id are changing randomly. so if I try to locate a id, next time I run the selenium code i get an error because the id changes for next run

What can i do to capture ids every run ?

For what you are describing locating elements by Id is not a good choice.

You would have much more success using different techniques such as class, xpath, or a combination of both

If you link a piece of your HTML code I could try to help you write a decent xpath/css locator.