How to fix Playwright "strict mode violation" for locators?

Playwright

Strict mode means a locator used for an action must match exactly one element.

Refine the locator with role/name/test id, or intentionally choose one element.

// Better: unique locator
await page.getByRole('button', { name: 'Save changes' }).click();

// If needed: pick one explicitly
await page.locator('.save-button').first().click();

Prefer unique semantic locators over .first() so tests stay stable.