最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cypress and cookies popup: how to get rid of it - Stack Overflow

programmeradmin7浏览0评论

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!

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!

Share Improve this question asked Apr 8, 2021 at 8:46 Don DiegoDon Diego 1,5083 gold badges26 silver badges55 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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.

发布评论

评论列表(0)

  1. 暂无评论