【问题标题】:TestCafe - Error in fixture.beforeEach hookTestCafe - fixture.beforeEach 钩子中的错误
【发布时间】:2019-10-01 16:13:41
【问题描述】:

我正在使用 Testcafe 为应用程序进行一些 e2e 测试。对于我的一个固定装置,我使用的是 beforeEach。我的选择器正在等待元素出现,然后在页面上单击它。有时这个测试通过,有时这个测试失败。非常不一致。

代码:

fixture`Ingredient Details [En]`   
    .page`${url}en/something`   
    .beforeEach(async t => {              
        await t   
          .click(button1)   
          .wait(1000)
    })

我得到的错误:

1) - Error in fixture.beforeEach hook -
      The specified selector does not match any element in the DOM tree.   

> | Selector('#accept-button')

似乎存在某种时间问题,有时它没有正确等待?

谢谢。

【问题讨论】:

  • 如果没有工作示例,很难确定问题的原因。请为您的网站提供一个小项目或 URL,以证明该问题。
  • 我认为 DOM 元素有时加载时间过长。这就是为什么它会根据网络失败。有没有办法等到所有 DOM 元素完成加载后再执行代码?谢谢。
  • TestCafe 一直等到目标页面完全加载,所以这里应该没有错误。但是,您可以尝试增加选择器超时值。请参考以下文章:devexpress.github.io/testcafe/documentation/test-api/…

标签: testing automated-tests e2e-testing testcafe end-to-end


【解决方案1】:

Testcafe 提供了一种调试方法t.debug(),它可以停止测试并允许您使用浏览器的开发工具调试问题。也许通过这样做,您可以检查在您尝试单击按钮时是否已加载元素。

欲了解更多信息:https://devexpress.github.io/testcafe/documentation/test-api/debugging.html#client-side-debugging

【讨论】:

    猜你喜欢
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-15
    • 1970-01-01
    • 2019-09-25
    • 1970-01-01
    相关资源
    最近更新 更多