柏树是否可以等待某些元素出现?

时间:2020-08-12 22:03:52

标签: javascript testing cypress visual-testing

我想让柏树等到我的Web应用程序完全打开为止。 有些元素彼此独立加载,我必须等待全屏加载,因为在此之后,我想用percy拍摄快照。 我该如何处理?是否可以使其依赖于某些html类?

1 个答案:

答案 0 :(得分:0)

针对此问题的柏树骇客为cy.get('button', {timeout: 2000})

但是,我建议使用cypress-wait-until之类的库。这将为您提供类似

的语法
  cy.waitUntil(() =>
    cy.get("input[type=hidden]#recaptchatoken")
      .then($el => $el.val()))
      // ... then, check that it's valid string asserting about it
      .then(token => expect(token).to.be.a("string").to.have.length.within(1,1000));