Playwright getByRole('button').click() with two buttons: "strict mode violation: getByRole('button') resolved to 2 elements"
@aiden-f-dsouza▲ -3 net votes
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.