How can I get the unique id of the element in selenium webdriver.
For example email id creation:
Each time the system creates a unique id for the email id.
How can we use that specific id in selenium webdriver for testing when it is constantly changing ?

  • 1
    What problem are you trying to solve? what is email id? is it id attribute of some element? "Each time its creating" who is that "it"? "and we cannot create a new one with already existing name" what do you mean by "create"? Why are you trying to create something with already existing name?. Please answer all these question. Yet I'm voting to close this one as "unclear what you're asking"
    – Alexey R.
    Commented Apr 4, 2018 at 9:41
  • 1
    Is this same like- sqa.stackexchange.com/questions/18342/…
    – Bharat Mane
    Commented Apr 4, 2018 at 13:53

1 Answer 1


When the element ID is dynamic and uniquely generated each time - usually a database ID or the link - your options are:

  • work with designers to have a fixed css ID on the element or a surrounding element
  • use surrounding code elements, ID's and classes to identify the element without using the ID

Not the answer you're looking for? Browse other questions tagged or ask your own question.