cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.19k forks source link

"Removing cookie failed for" error in Firefox after setting cookie via `cy.setCookie()` #6375

Closed joshuacrawford closed 3 years ago

joshuacrawford commented 4 years ago

Current behavior:

One in every ten or so runs on Firefox I get the following error:

image

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

jennifer-shehane commented 4 years ago

@joshuacrawford Just to verify, this behavior does not happen in Chrome?

Can you give an example of the code you have in your support/index.js file. Feel free to remove sensitive information, I'd just like a general idea of the code you're running.

joshuacrawford commented 4 years ago

@jennifer-shehane Correct. We have been using this code for a few months now and haven't had an issue before. The only issue seems to be when we are running Firefox.

Sure here is an example of what we have. Like I mentioned I'm not 100% sure this is the code causing the issue since its adding a cookie and the error before was about removing a cookie, but this is the only place our production host name is used in the code

beforeEach(function() {
  cy.setCookie('optout', 'true', {domain: "prod_host.com"})
});
joehansen commented 4 years ago

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:

CypressError: cy.clearCookies() had an unexpected error clearing cookies in Firefox.

Removing cookie failed for: {"url":"https://DOMAIN/auth","name":"JSESSIONID"} Error: Removing cookie failed for: {"url":"https://DOMAIN/auth","name":"JSESSIONID"} throwError@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:95:36 clear/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:105:16 clear@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:100:10 clear@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:110:6 clearCookie@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:158:17 invoke/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:44:33 invoke@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:43:20 connect/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:63:16 [164]</Emitter.prototype.emit@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14233:20 [193]</Socket.prototype.onevent@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:19755:10 [193]</Socket.prototype.onpacket@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:19713:12 [163]</module.exports/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14096:15 [164]</Emitter.prototype.emit@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14233:20 [191]</Manager.prototype.ondecoded@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:19221:8 [163]</module.exports/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14096:15 [164]</Emitter.prototype.emit@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14233:20 [188]</Decoder.prototype.add@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:18597:12 [191]</Manager.prototype.ondata@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:19211:16 [163]</module.exports/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14096:15 [164]</Emitter.prototype.emit@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14233:20 [169]</Socket.prototype.onPacket@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:15282:14 [169]</Socket.prototype.setTransport/<@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:15099:10 [164]</Emitter.prototype.emit@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:14233:20 [170]</Transport.prototype.onPacket@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:15720:8 [170]</Transport.prototype.onData@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:15712:8 [175]</</WS.prototype.addEventListeners/this.ws.onmessage@moz-extension://90b1cd3e-350d-4508-b1ab-fc4e7cd71069/background.js:16855:10 From previous event: automation@https://DOMAIN/__cypress/runner/cypress_runner.js:94182:14 automate@https://DOMAIN/__cypress/runner/cypress_runner.js:85555:22 automateCookies@https://DOMAIN/__cypress/runner/cypress_runner.js:85569:12 getAndClear/<@https://DOMAIN/__cypress/runner/cypress_runner.js:85591:14 From previous event: getAndClear@https://DOMAIN/__cypress/runner/cypress_runner.js:85582:66 clearCookies@https://DOMAIN/__cypress/runner/cypress_runner.js:85825:14 runCommand/<@https://DOMAIN/__cypress/runner/cypress_runner.js:96904:33 From previous event: runCommand@https://DOMAIN/__cypress/runner/cypress_runner.js:96883:14 next@https://DOMAIN/__cypress/runner/cypress_runner.js:97026:14 From previous event: next@https://DOMAIN/__cypress/runner/cypress_runner.js:97026:34 From previous event: run/promise<@https://DOMAIN/__cypress/runner/cypress_runner.js:97067:37 From previous event: run@https://DOMAIN/__cypress/runner/cypress_runner.js:97060:19 addCommand/cy[name]@https://DOMAIN/__cypress/runner/cypress_runner.js:97471:11 @https://DOMAIN/__cypress/tests?p=cypress\support\index.js-305:16:99590 setRunnable/runnable.fn@https://DOMAIN/__cypress/runner/cypress_runner.js:97713:24 callFn@https://DOMAIN/__cypress/runner/cypress_runner.js:39612:21 ../driver/node_modules/mocha/lib/runnable.js/</Runnable.prototype.run@https://DOMAIN/__cypress/runner/cypress_runner.js:39599:13 onRunnableRun/<@https://DOMAIN/__cypress/runner/cypress_runner.js:100832:28 From previous event: onRunnableRun@https://DOMAIN/__cypress/runner/cypress_runner.js:100820:10 action@https://DOMAIN/__cypress/runner/cypress_runner.js:93999:61 patchRunnableRun/Runnable.prototype.run@https://DOMAIN/__cypress/runner/cypress_runner.js:99592:13 next@https://DOMAIN/__cypress/runner/cypress_runner.js:40114:10 ../driver/node_modules/mocha/lib/runner.js/</Runner.prototype.hook/<@https://DOMAIN/__cypress/runner/cypress_runner.js:40158:9 timeslice@https://DOMAIN/__cypress/runner/cypress_runner.js:34084:27

Because this error occurred during a 'before each' hook we are skipping all of the remaining tests.

steppefox commented 4 years ago

Same problem, Cypress 4.0.2, Firefox 73.0.1

Cypress.Cookies.debug(true);

const cookieValue = '123';
cy.setCookie('someToken', cookieValue);

Cypress.Cookies.defaults({
  whiteList: ['someToken'],
});

Trace:

Error: Removing cookie failed for: {"url":"http://.test.com/","name":"someToken"}

Because this error occurred during a 'before each' hook we are skipping all of the remaining tests.
    throwError@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21040:36
    clear/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21050:16
    clear@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21045:10
    clear@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21055:6
    clearCookie@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21103:17
    invoke/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:20989:33
    invoke@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:20988:20
    connect/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:21008:16
    [11]</Emitter.prototype.emit@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8194:20
    [187]</Socket.prototype.onevent@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:18210:10
    [187]</Socket.prototype.onpacket@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:18168:12
    [10]</module.exports/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8057:15
    [11]</Emitter.prototype.emit@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8194:20
    [185]</Manager.prototype.ondecoded@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:17676:8
    [10]</module.exports/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8057:15
    [11]</Emitter.prototype.emit@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8194:20
    [181]</Decoder.prototype.add@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:17050:12
    [185]</Manager.prototype.ondata@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:17666:16
    [10]</module.exports/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8057:15
    [11]</Emitter.prototype.emit@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8194:20
    [16]</Socket.prototype.onPacket@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:9243:14
    [16]</Socket.prototype.setTransport/<@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:9060:10
    [11]</Emitter.prototype.emit@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:8194:20
    [17]</Transport.prototype.onPacket@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:9681:8
    [17]</Transport.prototype.onData@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:9673:8
    [22]</</WS.prototype.addEventListeners/this.ws.onmessage@moz-extension://64a48eee-5330-3744-ad83-75c4686f90cc/background.js:10816:10
Romero-jace commented 4 years ago

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"}

san-slysz commented 4 years ago

Also producing. Our test is fairly simple : login + visit() in a before each, then a simple get in the it(). The test runs fine using Chrome or Electron.

Error: Removing cookie failed for: {"url":"https://ourCompanyDomain/aClientId","name":"__ourCookieName"}

We do not use a peculiar method to interact with the cookies, so I guess it's just the "natural" removal cypress it doing when entering a it(). Strangely enough, some similar tests do not produce. If it helps, I can give more details via MP.

kbabyk commented 4 years ago

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.

nikhilem commented 4 years ago

The error seems to occur only when the domain option is used. Works fine otherwise

  // Errors out on firefox
  cy.setCookie("property", "test", { domain: "localhost:3000" });

  // Works fine
  cy.setCookie("property", "test");
nadeem4n commented 4 years ago

The error happens in beforeEach hook since Cypress clears cookies before each of it() run. Adding the following in beforeEach() seems to make the tests pass but it's not a solution:

cy.clearCookie('the_problematic_cookie')

With this, if you re-run the test suite it fails the before() (i.e. beforeAll) hook with same error. Hitting re-run from there again makes everything work fine and so on.

symon-skelly commented 4 years ago

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.

AlexK777 commented 4 years ago

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.

jennifer-shehane commented 4 years ago

@kbabyk Your error is different from the Removing cookie failed for error. There is likely something malformed about the cookie you were trying to set. Please open a new issue if this isn't resolved.

I haven't been able to recreate this error with the information provided.

This is likely more specific than just setting a cookie value. It may be dependent on the domain being tested or the value being set. We'll need more information in order to begin fixing this issue.

Sathish787 commented 4 years ago

Same issue here, Cypress 4.5.0 and Firefox 75: (basic setup environment) 2nd test fails in the suite with error "failed to remove cookies..." if suite has beforeEach() hook. Also, Firefox window is not closing after suite execution and second suite fails bcoz of Firefox instance already exist. Execute test by "npx cypress run -b firefox --headed" for second issue

It would be really helpful if these issues are addressed soon. Or are there any alternative available to overcome these issues by setting Firefox preferences

BiosBoy commented 4 years ago

Same problem here...

estefafdez commented 4 years ago

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(); })

Sathish787 commented 4 years ago

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))

before("Suite Setup", () => {
        Cypress.Cookies.defaults({ whitelist: "sessionID" })
        cy.signOnApplication()
 })

beforeEach("Test Setup", () => {
      Cypress.Cookies.preserveOnce("sessionID")
 })
chryton commented 4 years ago

I am running into the same issue trying to run FF tests against Shopify stores. Chrome is fine:

  1) Cart Page Tests
       "before each" hook for "Items can be removed from cart":
     Error: Removing cookie failed for: {"url":"http://my-store.myshopify.com/","name":"_shopify_y"}

EDIT: This is also happening regardless of running it parallel and is not consistent in each run. Sometimes one container is fine and sometimes both fail after running the first spec.

yanfengliu commented 4 years ago

Still running into the same issue on Cypress 4.11 and Firefox 68. Works on Chrome. Interestingly, the cookie does seem to get cleared according to Cypress.Cookies.debug(), but still throws an error saying that removing cookie failed.

RomanBoiko1 commented 4 years ago

Hi Guys

I have managed to overcome that obstacle by deleting cookies one by one. So the next code helped me:

cy.getCookies().then((cookies) => cookies.forEach(cookie => cy.clearCookie(cookie.name)));

briandorian commented 4 years ago

Happening with latests versions of cypress and firefox :(

RomanBoiko1 commented 4 years ago

Happening with latests versions of cypress and firefox :(

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.

briandorian commented 4 years ago

Happening with latests versions of cypress and firefox :(

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.

Thanks for your reply! I manage to execute successfully the first test of the spec, however, after that first one, I can't preserve the cookies with the usual commands and for some reason (I think it's internal firefox behavior), the cookies are still being deleted at the beginning of the test. And ofc, keep doing a full log in and log out for every test within every spec is not sustainable. Hope it makes sense

briandorian commented 4 years ago

You were actually correct. I managed to have it all running, deleting the cookies one by one after each test. I was mistaken on the implementation! Thanks

Jacek-fstack commented 4 years ago

Same thing happening for me in cypress 5.3 and latest Firefox, NOT happening in Chrome

RomanBoiko1 commented 4 years ago

Same thing happening for me in cypress 5.3 and latest Firefox, NOT happening in Chrome

Have you tried to delete one by one?

Jacek-fstack commented 4 years ago

Same thing happening for me in cypress 5.3 and latest Firefox, NOT happening in Chrome

Have you tried to delete one by one?

Yeah, had some random error popping up [can't check it right now - running my suite] but I need to delete them in between log out / log in, not only before and/or after test.

RomanBoiko1 commented 4 years ago

I simply created my own cypress command. You can run it even in the middle of the test run:

clearAllCookies: () => {
    if (Cypress.isBrowser('firefox')) {
      cy.getCookies({ log: false }).then((cookies) =>
        cookies.forEach((cookie) => cy.clearCookie(cookie.name, { log: false })),
      );
      cy.log('clearCookies');
    } else {
      cy.clearCookies();
    }
  }
Jacek-fstack commented 4 years ago

Thanks, I'll give it a shot!

Jacek-fstack commented 4 years ago

Yeah, same exact thing happens:

Removing cookie failed for: {"url":"https://XXXXXX.com/","name":"token"}

Because this error occurred during a before each hook we are skipping all of the remaining tests.
LandGod commented 4 years ago

+1 for this issue.

I have an entirely self-contained test that only fails when I do "Run all tests" due to Removing cookie failed error. Not a single one of my tests fails by itself, and top it off, the cookie that fails to be deleted is totally irrelevant.

This would also be a lot less infuriating if I could just ignore that specific error since it has nothing to do with what I'm actually testing. But we're not allowed to do that either. Ugh.

(Also, there is no console trace and clicking the button to print the error in the console does nothing.)

vdechef commented 3 years ago

+1

I cannot use the workaround described above, because I need to clear the cookies before each test suite, not after.

The cookies removal work one time out of two.

levenleven commented 3 years ago

Still happens (sometimes) in Firefox 82

Error:

Removing cookie failed for: {"url":"http://.example.com/","name":"_gid"}

Because this error occurred during a before all hook we are skipping the remaining tests in the current suite: Example Test

Stack trace:

throwError@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13358:36 clear/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13368:16 From previous event: clear@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13363:10 From previous event: clear@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13373:6 clearCookie@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13421:17 invoke/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13307:33 From previous event: invoke@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13306:20 connect/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:13326:16 [164]</Emitter.prototype.emit@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14230:20 [199]</Socket.prototype.onevent@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:20095:10 [199]</Socket.prototype.onpacket@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:20053:12 [163]</module.exports/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14093:15 [164]</Emitter.prototype.emit@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14230:20 [197]</Manager.prototype.ondecoded@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:19561:8 [163]</module.exports/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14093:15 [164]</Emitter.prototype.emit@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14230:20 [191]</Decoder.prototype.add@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:18931:12 [197]</Manager.prototype.ondata@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:19551:16 [163]</module.exports/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14093:15 [176]</Emitter.prototype.emit@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:16648:20 [168]</Socket.prototype.onPacket@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14754:14 [168]</Socket.prototype.setTransport/<@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:14571:10 [176]</Emitter.prototype.emit@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:16648:20 [169]</Transport.prototype.onPacket@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:15192:8 [169]</Transport.prototype.onData@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:15184:8 [174]</</WS.prototype.addEventListeners/this.ws.onmessage@moz-extension://cd5ab0b2-4fc6-41e8-8cb5-40cea7f2225b/background.js:16321:10
khotsoshomang commented 3 years ago

I am experiencing this issue using Cypress 6.6.0, Cypress is not a good framework for cross browser testing

kunwardeep commented 3 years ago

I am experiencing this issue using Cypress 6.7.1 and FF 86

y2keeper commented 3 years ago

Same issue using Cypress 6.8.0 and FF 86...

I simply created my own cypress command. You can run it even in the middle of the test run:

clearAllCookies: () => {
    if (Cypress.isBrowser('firefox')) {
      cy.getCookies({ log: false }).then((cookies) =>
        cookies.forEach((cookie) => cy.clearCookie(cookie.name, { log: false })),
      );
      cy.log('clearCookies');
    } else {
      cy.clearCookies();
    }
  }

Based on that I have the following working for me:

    afterEach(() => {
        if (Cypress.isBrowser('firefox')) {
            cy.getCookies({log: false}).then((cookies) =>
                cookies.forEach((cookie) => cy.clearCookie(cookie.name, {log: false})),
            );
            cy.log('clearCookies');
        } else {
            cy.clearCookies();
        }
    })
dkulchykovskyi commented 3 years ago

just FYI: still hapens in cypress 7 when running on firefox 87. the work around provided by @y2keeper works when afterEach is in describe.

Same issue using Cypress 6.8.0 and FF 86...

I simply created my own cypress command. You can run it even in the middle of the test run:

clearAllCookies: () => {
    if (Cypress.isBrowser('firefox')) {
      cy.getCookies({ log: false }).then((cookies) =>
        cookies.forEach((cookie) => cy.clearCookie(cookie.name, { log: false })),
      );
      cy.log('clearCookies');
    } else {
      cy.clearCookies();
    }
  }

Based on that I have the following working for me:

    afterEach(() => {
        if (Cypress.isBrowser('firefox')) {
            cy.getCookies({log: false}).then((cookies) =>
                cookies.forEach((cookie) => cy.clearCookie(cookie.name, {log: false})),
            );
            cy.log('clearCookies');
        } else {
            cy.clearCookies();
        }
    })
melibe23 commented 3 years ago

This is still reproducible in FF 89 and Cypress 7.4.0. image I am not using the command clear cookies, this is my before

context(`Product Info Card - Logged state`, () => {
        before(() => {
          cy.setCookie(`xxxxx.session`, linkedinCookie)
          cy.visit(path)
        })

I will have to skip FF testing on this, right?

@jennifer-shehane what is the information needed for this ticket? Maybe I can help with that because I can reproduce the bug.

I can reproduce only in FF. Not reproducible in Chrome 91 nor in Edge.

in my support/index.js I have the following:

before(() => {
  cy.task('log', `Domain: ${Cypress.config().baseUrl}`)
  cy.task(`log`, `UserAgent: ${navigator.userAgent}`)
  // const browserInfo = JSON.stringify(Cypress.browser.name, null, '\t')
  cy.task(`log`, `Browser Name: ${Cypress.browser.name}`)
  cy.task(`log`, `Browser Version: ${Cypress.browser.version}`)
})

after(() => {
  cy.task('log', `Domain: ${Cypress.config().baseUrl}`)
})

require('./commands')
require('cypress-terminal-report/src/installLogsCollector')()
require('@cypress/skip-test/support')
alexneo2003 commented 3 years ago

same issue cypress - 7.3.0 ff - 89 tests failed randomly

image

used default starter project without any manipulations with plugins/commands code to reproduce

  describe('Subdomain', () => {
    const BASE_URL = 'https://new.novaposhta.ua';

    it('SubDomain test', function () {
      cy.visit(BASE_URL);
    });

    it('SubDomain test', function () {
      cy.visit(`${BASE_URL}/dashboard/internet-orders`);
    });
  });

DEBUG log by cypress:launcher

cypress:launcher launching browser { browser: { displayName: 'Firefox', name: 'firefox', family: 'firefox', channel: 'stable', version: '89.0.0.7817', path: 'C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', profilePath: undefined, majorVersion: 89, info: undefined, custom: undefined, warning: undefined, isChosen: true, isHeaded: true, isHeadless: false }, url: 'about:blank' } +4m
  cypress:launcher spawning browser with args { args: [ 'about:blank', '-marionette', '-new-instance', '-foreground', '-start-debugger-server', '-no-remote', '-profile', 'C:\\Users\\Alex\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\firefox-stable\\interactive' ] } +4ms
  cypress:launcher firefox stderr: C:\Users\Alex\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\interactive\user.js:146: prefs parse error: unexpected escape sequence character after '\'
C:\Users\Alex\AppData\Roaming\Cypress\cy\production\browsers\firefox-stable\interactive\user.js:149: prefs parse error: unexpected escape sequence character after '\' +101ms
  cypress:launcher firefox stdout: 1623745358730        Marionette      INFO    Marionette enabled +719ms
  cypress:launcher firefox stdout: Started devtools server on 60340 +78ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. +731ms
  cypress:launcher firefox stdout: 1623745360847        Marionette      DEBUG   Setting recommended pref browser.tabs.unloadOnLowMemory to false +1s
  cypress:launcher firefox stdout: 1623745360848        Marionette      DEBUG   Setting recommended pref browser.toolbars.bookmarks.visibility to never
1623745360849   Marionette      DEBUG   Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1623745360849   Marionette      DEBUG   Setting recommended pref prompts.contentPromptSubDialog to false
1623745360851   Marionette      INFO    Listening on port 60341
1623745360852   Marionette      DEBUG   Marionette is listening +9ms
  cypress:launcher firefox stdout: 1623745361247        Marionette      DEBUG   Accepted connection 0 from 127.0.0.1:60386 +392ms
  cypress:launcher firefox stdout: 1623745361248        Marionette      DEBUG   Accepted connection 1 from 127.0.0.1:60387 +1ms
  cypress:launcher firefox stdout: 1623745361249        Marionette      DEBUG   Closed connection 0 +4ms
  cypress:launcher firefox stdout: 1623745361258        Marionette      DEBUG   1 -> [0,1,"WebDriver:NewSession",{"acceptInsecureCerts":true}] +6ms
  cypress:launcher firefox stdout: 1623745361261        Marionette      WARN    TLS certificate errors will be ignored for this session +3ms
  cypress:launcher firefox stdout: 1623745361276        Marionette      DEBUG   1 <- [1,1,null,{"sessionId":"ccc12111-5985-4373-91ec-38c78ace7480","capabilities":{"browserName":"firefox","browserVersion":"89.0" ... ox-stable\\interactive","moz:shutdownTimeout":60000,"moz:useNonSpecCompliantPointerOrigin":false,"moz:webdriverClick":true}}] +15ms
  cypress:launcher firefox stdout: 1623745361292        Marionette      DEBUG   1 -> [0,2,"Addon:Install",{"path":"C:\\Users\\Alex\\AppData\\Roaming\\Cypress\\cy\\production\\browsers\\firefox-stable\\interactive\\CypressExtension","temporary":true}] +16ms
  cypress:launcher firefox stderr: JavaScript warning: moz-extension://76719828-a0c7-4e1f-8602-c056e8c5f1ca/background.js, line 5566: unreachable code after return statement +77ms
  cypress:launcher firefox stderr: JavaScript warning: moz-extension://76719828-a0c7-4e1f-8602-c056e8c5f1ca/background.js, line 5566: unreachable code after return statement +10ms
  cypress:launcher firefox stdout: 1623745361393        Marionette      DEBUG   1 <- [1,2,null,{"value":"automation-extension@cypress.io"}] +13ms
  cypress:launcher firefox stdout: 1623745361397        Marionette      DEBUG   1 -> [0,3,"WebDriver:Navigate",{"url":"http://localhost:60209/__/#/tests/integration/spec.js"}] +4ms
GET /__/ 200 12.217 ms - -
GET /__cypress/runner/cypress_runner.css 200 4.552 ms - -
GET /__cypress/runner/cypress_runner.js 200 3.048 ms - -
  cypress:launcher firefox stderr: JavaScript warning: http://localhost:60209/__cypress/runner/cypress_runner.js, line 10980: unreachable code after return statement +884ms
  cypress:launcher firefox stderr: JavaScript warning: http://localhost:60209/__cypress/runner/cypress_runner.js, line 10980: unreachable code after return statement +28ms
  cypress:launcher firefox stdout: 1623745362455        Marionette      DEBUG   1 <- [1,3,null,{"value":null}] +148ms
GET /__cypress/static/favicon.ico 200 1.160 ms - -
GET /v1/buckets/monitor/collections/changes/changeset?collection=message-groups&bucket=main&_expected=0 200 155.030 ms - -
GET /v1/buckets/main/collections/message-groups/changeset?_expected=1595616291726 200 26.175 ms - -
GET /__cypress/runner/fonts/fa-solid-900.woff2 200 1.492 ms - 76120
GET /__cypress/iframes/integration/spec.js 200 4.311 ms - 872
GET /__cypress/tests?p=cypress%5Cintegration%5Cspec.js 200 1397.990 ms - -
GET /__cypress/tests?p=cypress%5Csupport%5Cindex.js 200 2141.045 ms - -
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +4s
GET /__cypress/runner/fonts/fa-regular-400.woff2 200 6.608 ms - 13600
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned.
JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +106ms
GET /__/ 200 1.126 ms - -
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +54ms
GET /__cypress/runner/cypress_runner.css 200 16.452 ms - -
GET /__cypress/runner/cypress_runner.js 200 2.264 ms - -
  cypress:launcher firefox stderr: JavaScript warning: https://new.novaposhta.ua/__cypress/runner/cypress_runner.js, line 10980: unreachable code after return statement +560ms
  cypress:launcher firefox stderr: JavaScript warning: https://new.novaposhta.ua/__cypress/runner/cypress_runner.js, line 10980: unreachable code after return statement +20ms
GET /__cypress/static/favicon.ico 200 1.268 ms - -
GET /__cypress/runner/fonts/fa-solid-900.woff2 200 0.949 ms - 76120
GET /__cypress/iframes/integration/spec.js 200 1.785 ms - 876
GET /__cypress/tests?p=cypress%5Cintegration%5Cspec.js 200 5.267 ms - -
GET /__cypress/tests?p=cypress%5Csupport%5Cindex.js 200 11.486 ms - -
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned.
JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +634ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned.
JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +1ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +1ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +1ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned.
JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +6ms
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +68ms
GET /dashboard/internet-orders 200 42.333 ms - -
  cypress:launcher firefox stderr: JavaScript error: resource://gre/modules/ExtensionChild.jsm, line 813: DataCloneError: The object could not be cloned. +112ms

log from console after `cypress run --browser firefox --headless

Error: Removing cookie failed for: {"url":"http://.new.novaposhta.ua/","name":"_gid"}
      throwError@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20536:36
      clear/<@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20546:16
  From previous event:
      clear@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20541:10
  From previous event:
      clear@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20551:6
      clearCookie@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20599:17
      invoke/<@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20484:33
  From previous event:
      invoke@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20483:20
      connect/<@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20503:16
      ../../node_modules/component-emitter/index.js/Emitter.prototype.emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:6122:20
      emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19835:15
      emitEvent@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19580:20
      onevent@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19567:18
      onpacket@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19531:22
      ../../node_modules/component-emitter/index.js/Emitter.prototype.emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:6122:20
      emitReserved@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19848:15
      ondecoded@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19115:14
      ../../node_modules/component-emitter/index.js/Emitter.prototype.emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:6122:20
      add@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:20173:23
      ondata@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:19107:22
      ../../node_modules/component-emitter/index.js/Emitter.prototype.emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:6122:20
      onPacket@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:16987:16
      setTransport/<@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:16796:14
      ../../node_modules/component-emitter/index.js/Emitter.prototype.emit@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:6122:20
      onPacket@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:17389:10
      onData@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:17382:10
      addEventListeners/this.ws.onmessage@moz-extension://77bde8f6-b167-4434-ae67-10e4228ff12e/background.js:18379:36
maga-polito commented 3 years ago

same issue ff 89, cypress 6.8.0, is this going to be solved soon?

alexneo2003 commented 3 years ago

same issue cypress - 7.3.0 ff - 89 tests failed randomly

image

I think there is a problem with deleting cookies by subdomains at this point in the source code https://github.com/cypress-io/cypress/blob/develop/packages/extension/lib/util.js#L5

symon-skelly commented 3 years ago

The issue is still occurring on Cypress 8.0 with Firefox 89, what more information is required at this time?

cypress-bot[bot] commented 3 years ago

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.

Vaclovas commented 3 years ago

this is still reproducible in 8.3.1, why this one is closed?

joydeep100 commented 2 years ago

@jennifer-shehane @flotwig Is there any update on this issue. We are still observing this issue with Cypress 6.3.0. Has the issue been fixed in any particular version?

marktnoonan commented 1 year ago

For what it's worth, I hit his again just now testing a Next.js site on localhost:

Screenshot 2023-09-08 at 6 13 39 PM

chandlerr88 commented 6 months ago

I have the same issue on Firefox as above

Screenshot_135