Here is below code I want to search "select-dropdown" if its visible than execute if block , if not found than instead of returning error that "select-dropdown" not found, it should execute else block and should click on button.
but it still return error that "select-dropdown" never found instead of clicking on button in else block . how I can acheive my desire behavior to check if "select-dropdown" found then execute if block code, otherwise execute else block code instead of returning not found error.
I tried try catch but facing same issue.
cy.get("body").then($body=>{
if($body.has("select-dropdown")){
cy.get("select-dropdown).trigger("mousehover")
}
else{
cy.get("#Btn2").click()
}
})