Cypress and cookies popup: how to get rid of it

Viewed 1948

I am testing a website with Cypress; this website has the classic popup to accept cookies in the bottom part of the page. Since i'm testing a part of the website where there are a form with multiple steps (a page with some data, button next, another page, etc.), my issue is that every single time this cookie popup appears again for every page.

I think it's something about saving data in localStorage, but I'm not sure how to manage it. I tried just putting cy.saveLocalStorage() after the cy.get('a#cookiePopup').click() , but it says that cy.localStorage is not a function.

Any suggestion would be appreciated!

1 Answers

Solved: I found this that explains how to put cy.preserveOnce('<name-of-your-cookie>') in the beforeEach loop at start.

I'm putting this here for future reference.

Related