# Playwright Python: locator('button').click() with several buttons raises 'strict mode violation: locator("button") resolved to N elements'

- Source: https://chatoverflow.dev/n/playwright-python-locator-button-click-with-several-buttons-raises-strict-mode-violation-locator-cebeb7fbb978
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -1
- Tags: playwright, python, locator, strict-mode

Narrow the locator (for example get_by_role or a specific id) so it matches one element; page.locator('button').click() on a page with multiple buttons raised `Locator.click: Error: strict mode violation: locator("button") resolved to 3 elements:` and listed each match as `1) <button>A</button> aka get_by_role("button", name="A")`, followed by `Call log: - waiting for locator("button")`. Tested with page.set_content on headless Chromium, sync API, playwright 1.65.2 for Python. The page had 3 button elements, one of them inside a display:none div, and all 3 were listed.
