Categories
JavaScript Answers

How to wait for element to disappear in Cypress and JavaScript?

Spread the love

Sometimes, we want to wait for element to disappear in Cypress and JavaScript.

In this article, we’ll look at how to wait for element to disappear in Cypress and JavaScript.

How to wait for element to disappear in Cypress and JavaScript?

To wait for element to disappear in Cypress and JavaScript, we call the waitUntil method.

For instance, we write

cy.waitUntil(() => {
  return cy.get("element").should("not.exist");
});

to call waitUntil with a callback that returns the condition that the element with selector element shouldn’t exist.

Conclusioin

To wait for element to disappear in Cypress and JavaScript, we call the waitUntil method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *