cypress: "Removing cookie failed for" error in Firefox after setting cookie via `cy.setCookie()`
Current behavior:
One in every ten or so runs on Firefox I get the following error:
Desired behavior:
Test code to reproduce:
In our support/index.js
file we have a beforeEach
that uses cy.setCookie()
to set a cookie that opts our automation out of any experiments that could be running on our site. Not sure if this is actually the reason for it since we are adding a cookie but the error says removing cookie, but that is the only place that has our main hostname instead of our test host
Versions
Cypress 4.0.0 Firefox 72.0.2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 19
- Comments: 46 (4 by maintainers)
just FYI: still hapens in cypress 7 when running on firefox 87. the work around provided by @y2keeper works when afterEach is in describe.
Is there any update on this issue? In order to use our test environment we have to set a cookie that uses the domain option, with this issue firefox cannot be used.
This will be a deciding factor over us using selenium against cypress as we must be able to automate using firefox.
For what it’s worth, I hit his again just now testing a Next.js site on localhost:
Same issue using Cypress 6.8.0 and FF 86…
Based on that I have the following working for me:
I’ve also ran into the issue on Cypress 4.0.2, Firefox 73. This is on a greenfield installation/tests. Only happening in FireFox.
Error: Removing cookie failed for: {"url":"http://.testSite.com/","name":"_gid"}
The code for this is done in cypress-io/cypress#14350, but has yet to be released. We’ll update this issue and reference the changelog when it’s released.
I simply created my own cypress command. You can run it even in the middle of the test run:
Same problem here with cypress 4.5.0 and firefox 76.0.1.
Adding cy.clearCookie(‘the_problematic_cookie’) do not solve the problem for me but clear all the cookies it does (and only on firefox):
cy.onlyOn('firefox', () => { cy.clearCookies(); })
Similar error setting cookies on Cypress 4.0.2, Firefox 73:
Error: CypressError: cy.setCookie() had an unexpected error setting the requested cookie in Firefox.
Reproducible each time we are trying to set cookies. Chrome works as expected.
We have the same issue with Firefox, but it happened every time. In Chrome everythings work fine. In Firefox 72 and Cypress 4.0.1 it crashes when clearing cookies:
Because this error occurred during a ‘before each’ hook we are skipping all of the remaining tests.
The issue is still occurring on Cypress 8.0 with Firefox 89, what more information is required at this time?
Thanks, I’ll give it a shot!
Same thing happening for me in cypress 5.3 and latest Firefox, NOT happening in Chrome
Please make sure you are clearing cookies at the end of each test, not in the beginning! By the way, I am using cypress 5.1.0 and Firefox 78.
This setup worked for me to execute all tests in a single spec file but this is not solution for executing all tests from multiple spec files.
Catch here is getting correct session id that used in your application.
Cypress team need to address close of firefox after all tests in spec file executed. (cypress open, run (headed or headless))
Seeing the same issue. Can only run one test at a time as it fails to clear cookies before the next test. Cypress 4.4.1 and Firefox 75.