Cypress · Junior · Question 46 of 75
How do you scope queries to one part of the page?
- 1
cy.get('form').scope(() => { ... }) - 2
cy.get('form').within(() => { ... }) - 3
cy.get('form').inside(() => { ... })
Show the answer
Correct answer: cy.get('form').within(() => { ... })
Explanation
Inside .within(), cy.get and cy.contains search only that element, avoiding matches elsewhere.