cy.get('#warn-dialog-submit') .should(()=>{}) //this disable the failure if the element does not exist .then(($el) =>{ if($el && $el.length){ cy.wrap($el).click() } })