cypress-io / cypress

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

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

Open rdwentmp opened 11 months ago

rdwentmp commented 11 months ago

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 commented 11 months ago

@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:

rdwentmp commented 11 months ago

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

jennifer-shehane commented 11 months ago

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

rdwentmp commented 11 months ago

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 commented 11 months ago

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

image
santiespindd commented 10 months ago

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

pranaya1997 commented 10 months ago

I am also facing same issue 😞

santiespindd commented 10 months ago

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 commented 10 months ago

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 commented 9 months ago

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

Seb33300 commented 9 months ago

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 commented 8 months ago

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 commented 7 months ago

Having same issue when running tests using headless browser only

suman8025 commented 7 months ago

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

eugenet8k commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 6 months ago

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 commented 6 months ago

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

NilminiDharmakeerthi94 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

Any new update on this ?

jennifer-shehane commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

@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 commented 4 months ago

Is there any fix to the above issue?

Prashika commented 4 months ago

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 commented 4 months ago

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

JRRS1982 commented 4 months ago
  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 commented 2 months ago

+1 added testIsolation: off solved the issue for me

anthony-bernardo commented 1 month ago

Got the same issue, using next

uziab commented 1 month ago

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 commented 1 week ago

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