Playwright · Middle · Question 32 of 75
What does locator.or() do?
const dialog = page.getByText("Confirm security settings");
const newEmail = page.getByRole("button", { name: "New email" });
await expect(newEmail.or(dialog).first()).toBeVisible();- 1Clicks the second locator if the first one fails
- 2Combines two locators so both must be visible
- 3Matches either locator, for when one of two may appear
Show the answer
Correct answer: Matches either locator, for when one of two may appear
Explanation
It handles UIs that show one of two states. Use first() because both might match at once.