Cypress · Junior · Question 68 of 75

Why is cy.get('.btn-primary:nth-child(3)') a fragile selector?

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.

Further reading

Problem with a question

Cypress · Junior · question 68

Test yourself

Take the Cypress · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz