cypress: Specs are failing randomly when cy.visit() command timed out

Current behavior:

screen shot 2018-10-23 at 11 40 29 am

  Test
    1) "before each" hook for "Approve an instance, for AWS provider, with the default data"
  0 passing (1m)
  1 failing

  1) Test
       "before each" hook for "Test":
     CypressError: Timed out after waiting '60000ms' for your remote page to load.

Your page did not fire its 'load' event within '60000ms'.

You can try increasing the 'pageLoadTimeout' value in 'cypress.json' to wait longer.

Browsers will not fire the 'load' event until all stylesheets and scripts are done downloading.

When this 'load' event occurs, Cypress will continue running commands.

Because this error occurred during a 'before each' hook we are skipping the remaining tests in the current suite: 'Test...'
      at Object.cypressErr (http://localhost:60970/__cypress/runner/cypress_runner.js:67594:11)
      at Object.throwErr (http://localhost:60970/__cypress/runner/cypress_runner.js:67559:18)
      at Object.throwErrByPath (http://localhost:60970/__cypress/runner/cypress_runner.js:67586:17)
      at timedOutWaitingForPageLoad (http://localhost:60970/__cypress/runner/cypress_runner.js:57781:17)
      at http://localhost:60970/__cypress/runner/cypress_runner.js:58390:18
      at tryCatcher (http://localhost:60970/__cypress/runner/cypress_runner.js:6846:23)
      at http://localhost:60970/__cypress/runner/cypress_runner.js:2163:41
      at tryCatcher (http://localhost:60970/__cypress/runner/cypress_runner.js:6846:23)
      at Promise._settlePromiseFromHandler (http://localhost:60970/__cypress/runner/cypress_runner.js:4868:31)
      at Promise._settlePromise (http://localhost:60970/__cypress/runner/cypress_runner.js:4925:18)
      at Promise._settlePromise0 (http://localhost:60970/__cypress/runner/cypress_runner.js:4970:10)
      at Promise._settlePromises (http://localhost:60970/__cypress/runner/cypress_runner.js:5045:18)
      at Async._drainQueue (http://localhost:60970/__cypress/runner/cypress_runner.js:1778:16)
      at Async._drainQueues (http://localhost:60970/__cypress/runner/cypress_runner.js:1788:10)
      at Async.drainQueues (http://localhost:60970/__cypress/runner/cypress_runner.js:1662:14)

Desired behavior:

The test should not fail in cy.visit() command.

Steps to reproduce:

cy.clearCookie('react').clearCookie('angular');
cy.clearLocalAndSessionStorage();
cy.getURLByEnv().then(url => {
        cy.visit(url);
        cy.loginThroughRequest(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
        cy.reload();
    });

Sorry for not providing the app’s url.

I get the same behavior if try to run the tests with cypress open or cypress run.

I don’t know if it’s a OS issue or its an issue with the steps I wrote or caching.

The problem occurs randomly, sometimes disconnected/connected the ethernet cable and the tests worked. Sometimes I retry running the tests and it works.

It’s important to state that before running each spec I do clearCache and localStorage as it caused problems in the past.

Versions

Cypress: 3.1.0 NodeJS: 8.12.0 OS: MacOS Mojave 10.14

Any solution is welcomed. Thanks in advance!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 25 (5 by maintainers)

Most upvoted comments

I encountered a similar issue very often. even the same test. sometimes it just fails. I wonder if anyway that we can debug or capture more log for troubleshooting.

  CypressError: Timed out after waiting '50000ms' for your remote page to load.

Your page did not fire its 'load' event within '50000ms'.

You can try increasing the 'pageLoadTimeout' value in 'cypress.json' to wait longer.

Browsers will not fire the 'load' event until all stylesheets and scripts are done downloading.

When this 'load' event occurs, Cypress will continue running commands.

Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Account Setup'

Having the same issue in Cypress 12.9.0.

I’m facing this issue with Cypress 9.5.0.

There are no domain switching in between or anything like that. It is very random. I was able to see it on the videos from the pipeline: Page just loads almost instantly but cy.visit is still waiting. As a temporary workaround - I’m enabling the retries for now.

Would be nice to get it sorted.

Having the same issue in Cypress 9.4.1. The bug has to be reopened @jennifer-shehane

I am facing this issue because domain changes on my app in between. Any solution?

We’re also experiencing the same issue, with a React SPA, even though the page is visibly done loading in the screenshot taken by Cypress. This only happens in CI, and also only randomly.

Everything works perfectly locally, but when ran on Bitbucket Pipelines, it flakes out consistently. Adding cy.visit('url', { timeout: 30000 }) solved it. Thanks! Something about Docker makes it need more time.