Cypress · Junior · Question 68 of 75
Why is cy.get('.btn-primary:nth-child(3)') a fragile selector?
- 1It depends on styling and position, which change often
- 2Cypress doesn't support any CSS pseudo-classes
- 3It's slower than XPath in every browser
Show the answer
Correct answer: It depends on styling and position, which change often
Explanation
A new button or a class rename breaks it. A data-cy attribute or role-based query is more stable.