I have a popup window which sometimes I need to close. Code like this works:
cy.get('body').then((truefalse) => {
if (truefalse.find('popup').length) {
cy.get('popup')
.find('button')
.contains('Close')
.should('be.visible')
.and('be.enabled')
.click();
} else {
}
});
This popup does not always load fast. I have added some shoulds before cy.get('body') to wait a bit but it did not always help. I tryed to add timeout:
if(truefalse.find('popup',{timeout: 10000}).length)
but it is not the way. Any suggestions not to add cy.wait()?