I am testing an Angular app in Cypress and I'm coming across an issue during the CI/CD run, which uses Docker. This is passing when I run it on my machine using the TestRunner, but not during the CI/CD run.
I wrote the following command to get rid of the overlay when needed:
cy.get(".cdk-overlay-backdrop").click()
As a result, I get the following error message: cy.click() can only be called on a single element. Your subject contained 2 elements. Pass {multiple:true} if you want to serially click each element.
I passed {multiple:true}
and I continue to get the same message.
This is how it appears in the dom:
<div class="cdk-overlay-container">
<div class="cdk-overlay-backdrop cdk-overlay-transparent-backdrop cdk-overlay-backdrop-showing"></div>
<div class="cdk-overlay-connected-position-bounding-box" dir="ltr" style="top: 0px; left: 0px; height: 100%; width: 100%"</div>
</div>
Is there any workaround for this?
Try to get the first element using eq(<<index>>)
.
cy.get(".cdk-overlay-backdrop").eq(0).click()