Cypress · Junior · Question 46 of 75

How do you scope queries to one part of the page?

Show the answer

Correct answer: cy.get('form').within(() => { ... })

Explanation

Inside .within(), cy.get and cy.contains search only that element, avoiding matches elsewhere.

Further reading

Problem with a question

Cypress · Junior · question 46

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