In cypress, how do I wait for a page to load?

一世执手 提交于 2019-12-01 04:04:30
Igor Shubovych

You can add some assert inside:

cy.click('#someButtonToNavigateOnNewPage');

cy.location('pathname', {timeout: 60000})
  .should('include', '/newPage');

cy.click('#YouAreOnNewPage');

You can change default timeout - by default it's 4000 ms (4 secs) - to ensure that user navigated the page. I've put a big number here - 60,000 ms - because I'm sure that 99% of users will leave if they do not have page loaded after 1 min.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!