cy.get("selector_for_your_button").then($button => { if ($button.is(':visible')){ //you get here only if button is visible } })