Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default blank page, this page was cleared by navigating to about:blank #28527

Closed
rdwentmp opened this issue Dec 14, 2023 · 41 comments · Fixed by #30864
Closed

Default blank page, this page was cleared by navigating to about:blank #28527

rdwentmp opened this issue Dec 14, 2023 · 41 comments · Fixed by #30864
Assignees

Comments

@rdwentmp
Copy link

rdwentmp commented Dec 14, 2023

Current behavior

During Cypress run the application page disappear and appear default blank page, after that test scenario fail with visibility of inputs. The issue occur randomly on different test scenarios, possibly some memory leak.
The Default blank page errors start to occur after upgrade Cypress version from 11.2.0 to 13.0.0.
I already set up migration guide and had to set up testIsolation: false, without that every test occur with default blank page, but still after done everything right the default blank page still occur random.
I think it looks like memory leak

image image

Desired behavior

Cypress behave stable without clearing cache with appearing Default blank page

Test code to reproduce

import { defineConfig } from 'cypress'
export default defineConfig({
  retries: {
    runMode: 2,
    openMode: 0,
  },
  video: false,
  numTestsKeptInMemory: 0,
  experimentalMemoryManagement: true,
  chromeWebSecurity: false,
  projectId: '4exo9z',
  defaultCommandTimeout: 20000,
  pageLoadTimeout: 20000,
  responseTimeout: 20000,
  requestTimeout: 20000,
  viewportWidth: 1400,
  viewportHeight: 800,
  screenshotOnRunFailure: true,
  reporter: 'junit',
  reporterOptions: {
    mochaFile: 'results/result.xml',
    toConsole: false,
  },
  env: {
    url: 'http://localhost:5080',
    CHROME_EXTRA_LAUNCH_ARGS: '--disable-gpu',
    codeCoverage: {
      exclude: ['**/tools/**/*.js'],
    },
  },
  e2e: {
    // We've imported your old cypress plugins here.
    // You may want to clean this up later by importing these.
    setupNodeEvents(on, config) {
      return require('./cypress/plugins/index.js')(on, config)
    },
    baseUrl: 'http://localhost:4200/',
    specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
    testIsolation: false,
  },
})

Cypress Version

13.0.0

Node version

v14.21.3

Operating System

linux, macos

Debug Logs

{
  "specName": "cypress%2Fe2e%2Factivities-tab%2Fadd-assumptions-additional-activity.spec.ts",
  "title": "Owner should add assumption for added equipment",
  "suiteName": "Add assumptions for additional activity",
  "testName": "add-assumptions-additional-activity Add assumptions for additional activity Owner should add assumption for added equipment",
  "testError": "Timed out retrying after 20000ms: Expected to find element: `[formcontrolname=assumptions]`, but never found it.",
  "testCommands": [
    "get [formcontrolname=assumptions]",
    "log \n            ⚠️ Could not find any coverage information in your application\n            by looking at the window coverage object.\n            Did you forget to instrument your application?\n            See [code-coverage#instrument-your-application](https://github.com/cypress-io/code-coverage#instrument-your-application)\n           `[@cypress/code-coverage]`"
  ]
}

Other

No response

@MikeMcC399
Copy link
Contributor

@rdwentmp

According to your issue description, you are using Node.js v14.21.3, which reached end-of-life on Apr 30, 2023 and is no longer supported.

Please check the Changelog for Cypress 13.0.0 and follow the recommendations there:

  • Node 14 support has been removed and Node 16 support has been deprecated. Node 16 may continue to work with Cypress v13, but will not be supported moving forward to closer coincide with Node 16's end-of-life schedule. It is recommended that users update to at least Node 18.

@rdwentmp
Copy link
Author

Ah that's really sad news, it looks like I missed that, will try to update node then

@jennifer-shehane
Copy link
Member

@rdwentmp We'll need some set of tests to run to see the issue and investigate, if the upgrade doesn't help.

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Dec 14, 2023
@rdwentmp
Copy link
Author

rdwentmp commented Dec 21, 2023

change-ctr-owner-not-started -- Change the owner of not started CTR -- Requestor should change CTR owner (failed) (attempt 2)

After update node version to 20.10.0 the error still randomly occurs. In this case I can put some code when the default start to occur from the screenshot:

changeCtrOwner(ctrOwner: string) {
    cy.message(`changeCtrOwner`)
    this.interceptChangeCtrOwner()
    this.interceptDelegateUsers()
    return this.getPxdRigidPipeAndFlowDesignCell()
      .should('contain.text', ctrOwner)
      .trigger('mouseenter')
      .then(() => this.getPxdEditOwnerBtn().should('be.visible').click())
      .then(() => this.waitDelegateUsers())
      .then((engineerNames) => {
        let newOwner = selectRandom(engineerNames)
        let newOwnerFullName: string = newOwner.fullName

        cy.message(`Change CTR owner to ${newOwnerFullName}`)
        this.selectCtrOwner(newOwner.fullName)
          .then(() => this.getDoneBtn().should('be.visible').click())
          .then(() => this.getYesConfirmBtn().should('be.visible').click())
        return this.waitChangeCtrOwner().then(() => {
          return cy.wrap(newOwnerFullName)
        })
      })
  }```

@rdwentmp
Copy link
Author

This Default blank page error usually occur on second attempt after failed test

image

@santiespindd
Copy link

I have same problem , after every test case , the blank page appears

@pranaya1997
Copy link

I am also facing same issue 😞

@santiespindd
Copy link

I just added this line in cypress.config.js and it has started to work

image

I am also facing same issue 😞

This Default blank page error usually occur on second attempt after failed test

image

@RMFTI
Copy link

RMFTI commented Jan 4, 2024

I just added this line in cypress.config.js and it has started to work

image

I am also facing same issue 😞

This Default blank page error usually occur on second attempt after failed test
image

I was having this same problem today and your solution helped me solve it, thank you very much! ☺

@kj-fiddler
Copy link

kj-fiddler commented Feb 15, 2024

https://docs.cypress.io/guides/core-concepts/test-isolation#Test-Isolation-Disabled
the tradeoffs for this solution ^

@Seb33300
Copy link

I am facing the same issue, if it can help, I am running tests on Windows.
For the other people facing that issue, are you also running tests on windows?

@Hakonovrebo
Copy link

Hakonovrebo commented Mar 22, 2024

cypress Versjon 13.7.0 (13.7.0.2514066)

Skjermbilde 2024-03-22 kl  07 27 08

stil having the same issue, on mac OS 14.3.1
even tho i have changed the cypress.config.js to
Skjermbilde 2024-03-22 kl  07 29 51

@nomercy360
Copy link

Having same issue when running tests using headless browser only

@suman8025
Copy link

I am also facing the same issue with chrome , cypress 13.7.3 and testIsolation: false
Randomly occurs

@eugenet8k
Copy link

eugenet8k commented Apr 26, 2024

The same issue that people above have. All my tests are snapshot verifications and I do up to 4 retries. Occasionally some tests after a second retry drop into a blank page.

This was not the issue in Cypress v13.4.0, but it seems it started happening somewhere around v13.5

I did have testIsolation: false in config already and it does not help at all.

Screenshot 2024-04-25 at 8 06 39 PM

@Daniel-Collins-QA
Copy link

Daniel-Collins-QA commented Apr 26, 2024

I am having the same issue today on v13.8.1. Like someone else here, I see it MOST of the time, but not all the time (like 98% of the time I get the bug. Didn't get it the first time). I also added testIsolation: false to my config, and it didn't help me any.

But I think I've found a workaround! It's a really laaaaame workaround, but in a pinch, maybe it'll help: just tuck everything into just ONE big test body section!

EXAMPLE:
This version of my test case with the meat of it looking like THIS failed. Step 1 worked right, to go to my designated URL, but then it went to a blank page right before 'Click on Text Box'

Screenshot 2024-04-26 001524

... but once I changed it to THIS, it succeeded! The only difference is that I moved all the "cy." commands under just one heading:

Screenshot 2024-04-25 235919

Please take all of this with a big pinch of salt... and PLEASE forgive any use on my part of poor terminology! As you can probably guess from the screenshots, it's only my first week learning Cypress.

@proko
Copy link

proko commented Apr 29, 2024

This helped me solve the issue.
With testIsolation enabled I had to do a new cy.visit() within the spect (in a beforeEach in my case)

@naseradd
Copy link

Do we have any news on that issue ? I got the same issue on my side and 'testIsolation' is not the good solution for it.

@jolujs
Copy link

jolujs commented May 30, 2024

@proko podrías compartir como lo solucionaste? te lo agradeceria.

@NilminiDharmakeerthi94
Copy link

NilminiDharmakeerthi94 commented Jun 3, 2024

Do we have any updates on the above issue? I'm also getting the same problem after upgrading the cypress v 13. 'testIsolation' doesn't work for me.

@naseradd
Copy link

naseradd commented Jun 4, 2024

I got a temprorary fix for now. I add an additional function in a generic beforeEach() in order to detect if the application is loaded or not and if it's not I am cy.visiting again.

I hope Cypress Team will provide a better solution for this :)

@Chafik-Marouf
Copy link

Any new update on this ?

@jennifer-shehane
Copy link
Member

Currently we do not regard this as an issue with Cypress. This change was intended to clear the page between tests.

If someone can provide an example to run where the tests are behaving in a way that is not intended by Cypress, we can investigate.

If you don't want your page to be cleared between tests, pass testIsolation: false to your cypress.config.js file to opt out of this behavior.

@naseradd
Copy link

naseradd commented Jul 4, 2024

I believe there’s a misunderstanding in my original post. The behavior I’m reporting is inconsistent, and it’s not related to the testIsolation configuration.

Consider a Cypress end-to-end testing file with multiple tests within a describe block (e.g., describe(it(...); it(...); it(...); ...)). Additionally, I've configured Cypress with the following settings:

retries: {
      openMode: true,
      runMode: true,
      experimentalStrategy: "detect-flake-and-pass-on-threshold",
      experimentalOptions: {
        maxRetries: 2,
        passesRequired: 1,
      },
    },

Here’s the observed behavior:

When Cypress encounters a failure during the initial test run, it doesn’t clear the page and retries the test according to the specified configuration (in this case, up to 2 retries).

However, if another test within the same run fails and Cypress attempts a retry, it does clear the page. This behavior differs from the initial test runs.

Please let me know if this explanation makes sense, or if you’d like me to provide clear examples.

@jennifer-shehane
Copy link
Member

@naseradd The original issue didn't mention using experimental retries. Is this issue isolated to experimental retries then?

Or does this behavior happen with just standard 'retries: #' set also.

This makes more sense to possibly have a situation where the state is not correctly reset on some retries but it is reset on others.

@testercs-tst
Copy link

Is there any fix to the above issue?

@Prashika
Copy link

Prashika commented Jul 23, 2024

Hi team,
I was getting this error while runAllSpecs files on start of second file execution :
Default blank page
This page was cleared by navigating to about:blank.
All active session data (cookies, localStorage and sessionStorage) across all domains are cleared.

Adding this line
image

testIsolation: false in cypress.config.js worked for me!
Thank you so much for this solution!

@naseradd
Copy link

I tried to reproduce the defect with a simplier sample but I am not able to reproduce it anymore unfortunately

@JRRS1982
Copy link

  1. Obviously turning testIsolation off is not a long term solution / good practice - please just no.
  2. Is there a session in use? The issue with the page clearing might be due to cy.session reloading the page when switching sessions, causing the test to lose its context, or maybe the old node version is not compatible.

@jamesryan-dev
Copy link

+1 added testIsolation: off solved the issue for me

@anthony-bernardo
Copy link

Got the same issue, using next

@uziab
Copy link

uziab commented Oct 10, 2024

experiencing the same issue on:

Cypress:        13.7.3   
Browser:        Chrome 123 (headless) 
Node Version:   v20.12.2

This is my config:

module.exports = defineConfig({
  chromeWebSecurity: false,
  defaultCommandTimeout: 15000,
  reporter: "cypress-multi-reporters",
  reporterOptions: {
    configFile: "cypress-reporter-config.json"
  },
  retries: 3,
  viewportWidth: 1280,
  viewportHeight: 1024,
  pageLoadTimeout: 120000,
  env: { CI, CYPRESS_OVERRIDE_MF_TEST_VERSION: process.env.CYPRESS_OVERRIDE_MF_TEST_VERSION },
  urlPort: port,
  urlDomain,
  e2e: {
    testIsolation: false,
    baseUrl: `http://${slug}.${urlDomain}${port}`,
    supportFile: "cypress/support/e2e.js",
    specPattern: "cypress/integration/**/*.{js,jsx,ts,tsx}",
    excludeSpecPattern: [
      "cypress/integration/*/helpers/**/*.{js,jsx,ts,tsx}",
      "cypress/integration/*/constants/**/*.{js,jsx,ts,tsx}"
    ],
    setupNodeEvents(on, config) {
      if (process.env.CI === "true") {
        require("dd-trace/ci/cypress/plugin")(on, config);
      }

      registerPlugins({ on, webpackPath: path.resolve(__dirname, "./webpack.config.js") });

      compareImagesPlugin(on);

      cypressLogToOutput.install(on, (type, event) => {
        if (event.level === "error" || event.type === "error") {
          return true;
        }

        return false;
      });
    }
  }
});

Any help would be appreciated. Issue is inconsistent and happens randomly on different specs.

@andradeg-luiza
Copy link

I just added this line in cypress.config.js and it has started to work

image

I am also facing same issue 😞

This Default blank page error usually occur on second attempt after failed test
image

Funcionou pra mim também <3 Valeuuu

@gouyang
Copy link

gouyang commented Dec 30, 2024

I also see this issue with testIsolation: false and retry

Cypress:        13.13.3                                                                        │
Browser:        Electron 118 (headless)                                                        │
Node Version:   v20.12.2 (/usr/bin/node-20)    

@eugenet8k
Copy link

Yes, testIsolation: false has nothing to do with the problem as many people say. But also some people say it helped. With that it could be assumed there are two ongoing issues that lead to the same result "Default blank page" browser crash, so one of those is helped with test isolation config and other isn't.

In our project we have many visual cypress tests, like hundreds. Now we are stuck on Cypress v13.4.0, any later version gets our coverage unstable and we see the above error with the rate like 1 on 50 tests, so our suite pretty much never pass.

IDK what's going on here, but at this point Cypress after v13.4 is useless on large coverages.

@eugenet8k
Copy link

eugenet8k commented Jan 4, 2025

@mschile did you see this bug report by chance? It seems after your change https://github.com/cypress-io/cypress/pull/28213/files this issue started to be observed by many people including myself. It appears to be random, but maybe we didn't notice the pattern.

Even if testIsolation: false set in cypress config, still, Cypress runner occasionally would redirect to blank page to reset environment. The updated code https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/runner.ts#L529 looks alright but a bit suspicious:

if (shouldAlwaysResetPage || !isLastTestThatWillRunInSuite) {
  let nextTestHasTestIsolationOn

  if (!isLastTestThatWillRunInSuite) {
    const nextTest = nextTestThatWillRunInSuite(test, getAllSiblingTests(topSuite, getTestById))
    const nextTestIsolationOverride = nextTest?._testConfig.unverifiedTestConfig.testIsolation
    const topLevelTestIsolation = Cypress.originalConfig['testIsolation']

    nextTestHasTestIsolationOn = nextTestIsolationOverride || (nextTestIsolationOverride === undefined && topLevelTestIsolation)
  }

...

    // This will navigate to about:blank if test isolation is on
  await testBeforeAfterRunAsync(test, Cypress, { nextTestHasTestIsolationOn })
}

Before your change nextTestHasTestIsolationOn would be set to topLevelTestIsolation is nextTestIsolationOverride is not set, but now it may hang undefined, which eventually forces the redirect to blank page.

Given the confirmed flakiness up the thread, my bet the issue is in this code...

I guess important note would be about nature of my tests. We do visual screenshot testing with retry set to 3. Based on the speed of page render sometimes it takes 1 try to pass but sometimes it takes 3 tries until the page is in desired state (as the reference screenshot).

Could it be that isLastTestThatWillRunInSuite is not accounting the retry sequence? So if it's the same test being executed again and it's also the last in the test suite, then the above code would assume it's the last test in the suite and redirect browser to blank page, but in fact there is two more retry runs for this test there.

Honestly it seems like what's going on, I will try to debug runner and check this out.

CC @jennifer-shehane

@eugenet8k
Copy link

eugenet8k commented Jan 4, 2025

@naseradd

Here’s the observed behavior:

When Cypress encounters a failure during the initial test run, it doesn’t clear the page and retries the test according to the specified configuration (in this case, up to 2 retries).

However, if another test within the same run fails and Cypress attempts a retry, it does clear the page. This behavior differs from the initial test runs.

Please let me know if this explanation makes sense, or if you’d like me to provide clear examples.

your observation is matching what I see in the code update (above) that likely cause this issue.

I guess with that, the simple workaround would be to pass {testIsolation: false} to the last test in the test suite if the retry strategy is used. This should trick the code above to not redirect Cypress browser to blank page.

Example:

describe(__filename, () => {
  before(() => {
    cy.visit('/maintenance')
  })

  it(
    'should match visual snapshot',
    () => {
      cy.compareSnapshot('maintenance')
    },
    {testIsolation: false}
  )
})

@eugenet8k
Copy link

The above hack didn't work. The override parameter should be passed as

describe(__filename, () => {
  before(() => {
    cy.visit('/maintenance')
  })

  it(
    'should match visual snapshot',
     {testIsolation: false}
    () => {
      cy.compareSnapshot('maintenance')
    }
  )
})

but for that we get

CypressError: The config passed to your test-level overrides has the following validation error:
CypressError: The `testIsolation` configuration can only be overridden from a suite-level override.

when setting on suite

describe(__filename, {testIsolation: false}, () => {
  before(() => {
    cy.visit('/maintenance')
  })

  it(
    'should match visual snapshot',
    () => {
      cy.compareSnapshot('maintenance')
    }
  )
})

no errors, but no effect of the hack. And with that another even simpler hack was found, just to add a fake last test that isn't subject for retry instability:

describe(__filename, () => {
  before(() => {
    cy.visit('/maintenance')
  })

  it('should match visual snapshot', () => {
    cy.compareSnapshot('maintenance')
  })

  // HACK: A fake last test in suite after which Cypress forcefully redirects to blank page for env reset
  // TODO: To remove once https://github.com/cypress-io/cypress/issues/28527 is fixed,
  // where Cypress doesn't account for retries of the last test in suite
  it('should', () => {})
})

this helped me to fix this issue! I am certain it should help everyone in this thread @rdwentmp, @Hakonovrebo, @suman8025, @Daniel-Collins-QA, @naseradd, @gouyang

I hope the CypressJS maintainers find an elegant monkey patch for mocha runner, to account for the test retry attempt and the number of retries in Cyress config in order to properly decide the value for isLastTestThatWillRunInSuite in https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cypress/runner.ts#L525

@mschile
Copy link
Contributor

mschile commented Jan 13, 2025

Hi @eugenet8k 👋🏼, thanks for your investigation and sorry for the delay with this response. Reading through the original issue description and the comments, it appears there are two issues being described.

The original issue is describing the intended behavior with test isolation which was enabled by default with Cypress v13.

The second issue as you've discovered relates to incorrectly navigating to about:blank when test isolation is disabled and the last test fails and then retries. As you've noted, you can workaround the issue by adding an empty test to the end which won't fail. You can also workaround the issue by enabling testIsolation but your before block would need to be a beforeEach.

I've opened #30864 to fix the issue.

@eugenet8k
Copy link

eugenet8k commented Jan 13, 2025

Fantastic news @mschile, thank you for the fix!

With the hack above we were able to move our giant coverage to the latest Cypress v13.17 and it increased the speed of execution for about 10-15%.

So with the hacks removed, we are all set, until next time...

@shaju007
Copy link

I have the same issue #30918

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.