【问题标题】:Cypress cy.visit doesn't load a website, Timed out after waiting赛普拉斯 cy.visit 不加载网站,等待后超时
【发布时间】:2021-09-09 18:10:58
【问题描述】:

我以前没有使用 Cypress 的经验,我被困在这样一个简单的问题上 - cypress 无法访问 united.com 网站。任何其他页面都可以轻松打开。 有什么建议吗?

visit https://www.united.com/en/us/
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.
cypress/integration/united.com.js:14:12
  12 | 
  13 |         //Step 1 - open main page
> 14 |         cy.visit(Cypress.env("env").UNITED_BASEURL)
     |            ^
  15 | 
  16 |         //Step 2 - select 'one-way flight'
  17 |         cy.get(mainRoot.body.oneway_radio_button, { timeout: 10000 }).should('be.visible').click()

【问题讨论】:

  • 最好将错误消息添加到问题本身而不是将其作为图像发布。
  • 另外,你能分享一下 UNITED_BASEURL 的设置位置吗?

标签: cypress pageloadtimeout


【解决方案1】:

您可以使用 Onload 功能。一旦您的页面触发了其加载事件,就会调用 onLoad。所有脚本、样式表、html 和其他资源都保证在此时可用。

链接:https://docs.cypress.io/api/commands/visit#Options

  onLoad: (contentWindow) => {
    // contentWindow is the remote page's window object
    if (contentWindow.angular) {
      // do something
    }
  },
})```  

【讨论】:

    【解决方案2】:

    答案是 - 本网站使用 Akamai Bot Management

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-02
      • 2021-12-12
      • 1970-01-01
      • 2021-10-28
      • 2020-05-30
      • 1970-01-01
      • 1970-01-01
      • 2019-12-14
      相关资源
      最近更新 更多