Search code examples
javascripttestingautomationcypress

Login through a web gateway with Cypress is timing out


I'm trying to perform some test for my webapp, but to do that I have to login to an external website, in order to do that my beforeEach statment is:

beforeEach(()=>{
    cy.visit('http://localhost:3001/')
    cy.get('#username')
        .type('user');
    cy.get('#password')
        .type('pass');
    cy.get('#fm1 > div > section.row.btn-row > input.btn.btn-submit.btn-block')
        .click();
})

The expected behaviour is that when i go to localhost:3001 it redirects me to another website where I set my login credentials and after clicking in login it redirects me to the original site.

The problem is that in the outsider website I'm receiving this

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 Drag and Drop, in cypr...'

I've tried to increase the pageLoadTimeout but it isn't working.


Solution

  • This can happen if there is an external asset on your page which cannot be resolved inside of cypress' browser. Maybe this is the case in your setting? I had a similar issue after updating the header-component in our enterprise application. Suddenly all e2e tests failed with this "load event not fired" bug.

    After doing some extensive research I discovered by accident that the newly inserted company logo was included via an absolute external URL. And by executing cypress inside our CI, this URL was blocked due to firewall rules. This resulted in a blocked page load event and thus in broken tests. After changing the image URL to a relative path everything worked fine again.

    So, maybe you have a similar case in your "outer" website?!