I am stuck by finding a specific button within my list of items... The button exists 3 times with exact same data-testid, but the parent is different. And I end with
error:
cy.click()can only be called on a single element. Your subject contained 3 elements. Pass{ multiple: true }if you want to serially click each element.
HTML:
<div data-testid="list-item">
<div>
<div>
<span data-testid="status1">
<button data-testid="details_button">click</button>
</div>
</div>
</div>
<div data-testid="list-item">
<div>
<div>
<span data-testid="status2">
<button data-testid="details_button">click</button>
</div>
</div>
</div>
How can I select the details_button of either status1 or status2?
My attempt was:
-
cy.get('[data-testid=status1]') .get('[data-testid="details_button"]').click() -
cy.get('[data-testid=status1]') .parent().parent() .get('[data-testid="details_button"]').click()