我正在尝试对我的 webapp 执行一些测试,但为此我必须登录到外部网站,为此我的 beforeEach 语句是:
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();
})
预期的行为是,当我转到 localhost:3001 时,它会将我重定向到我设置登录凭据的另一个网站,并在单击登录后将我重定向到原始站点。
问题是我在外部网站上收到了这个
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...'
我尝试增加 pageLoadTimeout,但它不起作用。
最佳答案
如果您的页面上有无法在 cypress 浏览器内解析的外部资源,就会发生这种情况。也许在您的环境中就是这种情况? 在我们的企业应用程序中更新 header 组件后,我遇到了类似的问题。突然间,所有端到端测试都因这个“未触发加载事件”错误而失败。
经过广泛研究后,我偶然发现新插入的公司 Logo 是通过绝对外部 URL 包含的。通过在我们的 CI 中执行 cypress,该 URL 因防火墙规则而被阻止。 这会导致页面加载事件受阻,从而导致测试中断。将图像 URL 更改为相对路径后,一切再次正常工作。
那么,也许您的“外部”网站中有类似的案例?!
关于javascript - 使用 Cypress 通过 Web 网关登录超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48705332/