Playwright · Junior · Question 24 of 75
What does chaining locators like this do?
page.getByRole("dialog").getByRole("button", { name: "OK" })- 1Finds both the dialog and the button separately
- 2Searches for the button only inside the dialog
- 3Clicks the dialog, then clicks the button
Show the answer
Correct answer: Searches for the button only inside the dialog
Explanation
Chaining scopes the search to the parent locator. It avoids matching an "OK" button elsewhere on the page.