Dom Elements Selection: data-testid
Explore how to select stable DOM elements for end-to-end tests using the data-testid attribute. Understand why common selectors can cause fragile tests and learn to implement dedicated attributes that improve test reliability and error diagnosis.
We'll cover the following...
We'll cover the following...
data-testid
The following is a deterministic event test:
As we’ve seen, one of the defects of the above test is its uselessness while something goes wrong while retrieving the elements.
The HTML of the RealWorld form is as follows:
If we want to avoid using the order of elements for the foundation of our test, we can leverage:
-
The type: text, email, and password
-
The placeholder ...