I have an application, where feedback pop up comes in a page randomly; like pop up may or may not come in the page after loading it for nearly 3000ms. How to handle this pop up in cypress.
I tried below code:
cy.get("div.QSIFeedbackButton").then(($body)=> {
if($body.find('.QSIWebResponsiveDialog-Layout1-SI_0rEzRx2V9yqm1Yq_close-btn > img')){
cy.get('.QSIWebResponsiveDialog-Layout1-SI_0rEzRx2V9yqm1Yq_content').contains('Help us improve our portal!')
cy.get('.QSIWebResponsiveDialog-Layout1-SI_0rEzRx2V9yqm1Yq_close-btn > img').click()
}
else {
cy.log('feed back pop up not found')
}
})
But this one always fails in IF block, when the pop up doesn't appear. I want to run the test gracefully, so that even if the pop up doesn't appear test should not fail & it should go to the else block. How can i do this in my test?