My test in Cypress does the following:

  1. Do the login
  2. On the next page clicks a button
  3. The button clicked in step 2, Cypress starts to load the correct URL but then the landing page (login screen from step 1) is displayed. I want that after clicking the button, Cypress waits for the page to load completely instead of returning to the login page.

I already tried cy.wait(), "pageLoadTimeout": 900000,, "includeShadowDom": true, "modifyObstructiveCode":false, "responseTimeout": 120000

This is what I got

enter image description here

Update: When I do cy.intercept('myurl/#').as('get#') cy.get('button').click()// after clicking on this button the page should loads completely cy.wait('#get') I got the following

enter image description here

2 Answers 2


It seems you want to wait until routes resolve. If that is the case, you need to explicitly tell Cypress to do just that.

For example, if I want Cypress to wait for a specific route, I write it like so:

cy.wait('@getRoute'); // once the route resolves, cy.wait will resolve as well

Or similar example with cy.route() and multiple routes:

cy.route('GET', '/api/route1').as('route1');
cy.route('GET', '/api/route2').as('route2');
cy.route('GET', '/api/route3').as('route3');


// again cy.wait() will resolve when all these routes resolve
cy.wait(['@route1', '@route2', 'route3']);

You can use cy.route() or cy.intercept(), the latter being a newer command with some differences you can read up on here.

Syntax and usage for cy.wait() could be found here, there're also similar examples with waiting for routes.

  • tks @pavelsaman. I see cy.route() and cy.serve are() are out to date, so I tried: cy.intercept('myurl/#').as('get#') // The URL I want cypress waits to load, ends with '#'. cy.get('buton').click() //after clicking this button the page needs to be loaded completely cy.wait('@get#'), but the same behaviour is still happening (it starts to load the right URL and returns to landing page). Please see my updated question using cy.intercept and the picture of the result. Mar 9, 2021 at 11:00
  • 1
    Fragment identifiers (that part after the first #) are not sent in HTTP requests to the server. They are only used within browsers on the client side so that browsers can do fancy stuff with them like automatically scroll to a certain part of a page. Therefore awaiting a url with a fragment identifier will always time out.
    – pavelsaman
    Mar 9, 2021 at 11:48
  • I appreciate your explanation. Understand the fragment identifiers. So I used another URL (took from DEV tools and named routes, that is: 'myurl.com/gw-pos/api/track/routes'). Based on this URL, I switched the code to cy.intercept('myurl.com/gwos/api/track/routes').as('getRoutes') cy.get('button').click() cy.wait('@getRoutes'), but this also times out: 'No request ever occurred' Mar 9, 2021 at 13:05
  • 1
    In general, your code is not wrong, but I'm like a blind person here when I can't try it out. Use browser's DevTools to find out what's going on on the site, you need to understand it before writing checks. Are you sure it's gwos? In your screenshots it's always gw-os. Use minimatch or regex in cy.intercept() and work the other way round, i.e. first you make it general, so it passes easily, and then you make the url more concrete to match exactly this route.
    – pavelsaman
    Mar 9, 2021 at 18:32

I am also facing the same issue on chrome browser. Some the XHR request is getting cancelled due to which my expected page is not loading. Refer :enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.