Cypress · Junior · Question 10 of 75
Why does Cypress recommend data-cy or data-test attributes for selectors?
- 1They make the page load faster in the browser
- 2They're stable and not tied to styling or text
- 3They're the only selectors Cypress supports
Show the answer
Correct answer: They're stable and not tied to styling or text
Explanation
Classes change with design, text changes with copy. Dedicated test attributes survive both and show the element is used by tests.