https://cypress.io logo
What is the best way to check that an element is p...
# e2e-testing
e
What is the best way to check that an element is present before clicking on it
Copy code
ts
cy.get('.search-button').click() // sometimes fails
// want to check if element is present before
But if I use
Copy code
ts
if(Cypress.$('.search-button').length) {
  // the block is never executed
}