Scenario: there are 4 buttons on the page with the same text (value). However, only one is visible, others are hidden.
A test like this:
Should display validations
Click "Save"
fails with the following error:
Error: locator.click: Error: strict mode violation: locator('text="Save"') resolved to 4 elements:
I can make the test work by updating a selector to include a specific parent element, e.g.:
Should display validations
Click id=modal--add >> "Save"
But I wonder if there's a way to target the only single visible button by text to keep the test more simple and generic.
Can't find any example in the Browser library documentation.
Note: this is a question about a new Browser library (Playwright), not Selenium.