Search code examples
cookiescypress

How to accept or close cookies popup as this popup doesn't have buttons to close/accept/decline?


I have cookies information banner as soon as I open a website and it doesn't has any buttons to close or accept or decline. I must wait for 10 seconds to get off this banner so then I can run my tests.

Any possible way to handle this type of cookies banner?

enter image description here

enter image description here


Solution

  • Try low level element .remove(), ref Element: remove() method

    cy.contains('div[role="dialog"]', 'We use cookies to help')
      .then($el => {
        const element = $el[0]
        element.remove()
      })