DEV Community

Discussion on: Selenium WebDriver and Dynamic Locators

Collapse
 
razgandeanu profile image
Klaus

Hi Daniela,
Thank you for taking the time to write that comment.
Yes, you can easily write a stable CSS Selector or XPath based on a certain attribute and the value of that attribute. It's ideal if you have an attribute like data-test or data-test-id, but very few web applications actually have those.
If someone would start a project from scratch, I would definitely encourage them to implement and use data-test or data-test-id attributes.

Collapse
 
danielavalero profile image
Daniela Valero

Hello Klaus, thanks a lot!