Here the id=popupY8cuUiMiDU is dynamic.I need to get the Y value from span but there are multiple listbox with the same span attribute taking Y option. How can I select from listbox as there is no unique attribute?


There're a few options.

  1. getting the element by what's not dynamic in its id

    //div[contains(@id, "popup")]

  2. using CSS


  3. asking developers to build in a unique test id for you

    e.g. there could be something like data-test-id=popup, then you'd use a css selector like so: [data-test-id=popup]

There could be more options, you can get more creative etc. But I'd keep it as simple as possible, which promotes maintainability and readability.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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