Reject a Playwright Locator That Matches Two Buttons
The advisor ranks role locators but warns that two Save buttons make the suggested action ambiguous.

A role-based locator can still match two buttons. The Playwright Locator Advisor marks whether each suggested locator is unique in your pasted HTML; check that count before copying a line into a test.
A good strategy can still be ambiguous
Paste:
<button>Save</button>
<button>Save</button>
<button aria-label="Cancel">X</button>
The live result shows three analyzed elements. For each Save button it offers page.getByRole('button', { name: 'Save' }), marked GOOD, and warns that it matches 2 elements. For Cancel it offers page.getByRole('button', { name: 'Cancel' }), marked BEST, because that role and name identify one element in the snippet.
This distinction is easy to miss. getByRole is a sensible locator method, but a sensible method does not make a particular locator unique. Copying the Save suggestion into click() would leave Playwright with two targets. First ask whether the duplicate is accidental. If both buttons belong on the page, scope to a dialog, form, or other meaningful container:
const checkout = page.getByRole('dialog', { name: 'Checkout' });
await checkout.getByRole('button', { name: 'Save' }).click();
That code is an example of a repair, not output from the pasted fragment; the sample HTML has no dialog. Add the scope only if the real page has one.
What the advisor actually inspects
The implementation parses a static HTML string in the browser. It infers a subset of roles and accessible names, then ranks role, label, test-ID, and CSS choices. It can spot duplicate names in the pasted fragment. It cannot reproduce the full browser accessibility tree or inspect a running page's state, shadow roots, or content loaded after the snapshot. Treat its BEST badge as a candidate to verify in Playwright, not a guarantee about production DOM.
Playwright itself recommends locators based on user-facing roles and names and enforces strictness for actions requiring one element. Run the proposed locator against the real page and check its count in the state where the test failed. If the name is ambiguous to a user too, improving the product's accessible label can fix both the test and the interface. If the names are intentionally shared, scope the test instead.