错误:超出 ResizeObserver 循环限制

Yov*_*dad 0 javascript automation dom cypress resize-observer

我试图在某些应用程序中通过 google 自动登录,但收到此错误消息:(未捕获的异常)错误:超过 ResizeObserver 循环限制错误以下错误源自您的应用程序代码,而不是来自 Cypress。

超出 ResizeObserver 循环限制

当赛普拉斯检测到源自您的应用程序的未捕获错误时,它将自动使当前测试失败。

此行为是可配置的,您可以选择通过侦听 uncaught:exception 事件来关闭此行为。

这是我的代码:

describe('empty spec', () => {
  it('login multi domain ', () => {
    cy.visit('/login');
    cy.get('form > .flex').click({force:true});


    cy.origin(`https://accounts.google.com`, ()=>{
        cy.get("#identifierId").type("user");
        cy.get(".VfPpkd-LgbsSe-OWXEXe-k8QpJ").click({force:true});
        cy.get(`#password`).type("pass");
        cy.get(".VfPpkd-LgbsSe-OWXEXe-k8QpJ").click({force:true});
    })
  })
})
Run Code Online (Sandbox Code Playgroud)

提前致谢

Ali*_*man 5

您可以从消息中看到这是应用程序中的错误。文档的这一部分给出了一些建议,以关闭所有未捕获的异常处理,以了解如何绕过错误以进行测试。

这是保守的方法

  Cypress.on('uncaught:exception', (err, runnable) => {
    if (err.message.includes('ResizeObserver loop limit exceeded')) {
      // ignore the error
      return false   
    }
  })
Run Code Online (Sandbox Code Playgroud)

通过该if()声明,您只是忽略了该特定错误。

根据这个问题ResizeObserver - Loop limit gone ,该消息是良性的,可以忽略。