Data-testid Attribute for Automation Testing: Why it is Important?
Ever written an automated test, only to have it fail the following day because the 'Submit' button changed its class name? Frustrating, I'm sure. Why are UI tests so flaky and why are selectors so flaky? Testers use CSS classes or IDs. Every time they see them, the class or ID changes every time the developers build the code. It makes automation brittle and long to update, especially due to the deep nesting and dynamic DOM elements. However, what if there was a more efficient way?