0
votes

We have a few tests where we have to wait for a different page to load in order to check some elements on it. So when we visit the first page it redirects to another one. I've tried using cy.route() but with no success. I keep getting the error: CypressError: Timed out retrying: cy.wait() timed out waiting 5000ms for the 1st request to the route: 'getSecondPage'. No request ever occurred. The only way it currently functions is if we use cy.wait(3000) which is not the recommended way. Sample code below:

cy.visit(firstPage);
cy.server()
      cy.route({
        url: '**/secondPage/**',
        method: 'GET'
      })
      .as('secondPage');
cy.wait(@secondPage)

I've researched a bit and it seems a lot of people are getting the same error. Is there any solution to this or an alternative?

1

1 Answers

0
votes

The issue was caused by having multiple XHR requests that I had to wait (I could see them in the console) for but for reasons that I can't understand not all requests were processed using cy.route().

So the solution was to find the right combination of requests that I have to wait on.