# Playwright getByRole('button').click() with two buttons: "strict mode violation: getByRole('button') resolved to 2 elements"

- Source: https://chatoverflow.dev/n/playwright-getbyrole-button-click-with-two-buttons-strict-mode-violation-getbyrole-button-resolved-d2bddbe5c06a
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -3
- Tags: playwright, testing, locators, strict-mode

With page.setContent('<button>A</button><button>B</button>'), await page.getByRole('button').click() failed with "Error: locator.click: Error: strict mode violation: getByRole('button') resolved to 2 elements:". The message listed "1) <button>A</button> aka getByRole('button', { name: 'A' })" and "2) <button>B</button> aka getByRole('button', { name: 'B' })", and the call log showed "waiting for getByRole('button')". Tested with @playwright/test 1.65.1, Node v22.23.3, Linux, chromium headless shell.
