I have some front-end test written in Groovy and I need to rewrite them in Cypress. I am currently having problem with rewriting an if condition to Cypress.If the popin window is displayed click on it, otherwise do nothing.
if ($(".PDialog").displayed) {
$(".p-submit-btn.confirm").click()
waitFor(2) {!$(".PDialog").displayed}
}
I have tried using a then clause. The current version that I have is this one ```
cy.get('body').then($res => {
if ($res.find('PDialog').length) {
cy.get('.p-submit-btn.confirm').click();
}
});
but it is still not working as the upper one.