You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When multiple elements match selector and I want to execute click() on locator I get error: Uncaught (in promise) clicking on "[data-action="add-to-cart"][aria-label="In den Warenkorb"][data-quantity-input="#quantity"]": strict mode violation, multiple elements returned for selector query
Code example:
const addToCartButton = page.locator('[data-action="add-to-cart"][aria-label="In den Warenkorb"]');
await addToCartButton.click();
There are multiple elements on page that match selector [data-action="add-to-cart"][aria-label="In den Warenkorb"].
It fails when i execute click() method
Expected behaviour
.locator() should return only the first element that matches the selector (similar to how HTML DOM Document querySelector() works).
Actual behaviour
.locator() return multiple elements.
The text was updated successfully, but these errors were encountered:
@nexus9111, if there are multiple elements that match the selector, then you will see the "strict mode violation" error. You will need to ensure that the element can be uniquely identified with a unique selector to it.
Brief summary
When multiple elements match selector and I want to execute click() on locator I get error: Uncaught (in promise) clicking on "[data-action="add-to-cart"][aria-label="In den Warenkorb"][data-quantity-input="#quantity"]": strict mode violation, multiple elements returned for selector query
Code example:
k6 version
v0.51.0
OS
Windows 10
Docker version and image (if applicable)
No response
Steps to reproduce the problem
There are multiple elements on page that match selector
[data-action="add-to-cart"][aria-label="In den Warenkorb"]
.It fails when i execute
click()
methodExpected behaviour
.locator()
should return only the first element that matches the selector (similar to how HTML DOM Document querySelector() works).Actual behaviour
.locator()
return multiple elements.The text was updated successfully, but these errors were encountered: