如何强制 selenium 具有与 Capybara 相同的默认等待时间

发布于 2024-11-29 23:10:28 字数 587 浏览 1 评论 0原文

我正在运行一些依赖于数据重新加载到页面中的测试。这些在 Capybara 中运行良好,它会在 has_content 处暂停,如果找不到它,则会重试。然而,他们在 Selenium 中失败了,Selenium 会立即解决问题并且不会进行任何重试。

Scenario: submit a question to the panel from its homepage
  When I submit the question "what's the best grease to use on my trucks?"
  Then I should be on the "Ruderiders" panel homepage
  And I should see the question entitled "what's the best grease to use on my trucks?" at the top of the feed
  • 在 Capybara 中工作
  • 在 Selenium 中失败(@javascript

我怎样才能强制 Selenium 进行与 Capybara 相同的等待和重试?

I'm running some tests that depend on data reloading into the page. These run fine in Capybara which pauses on has_content and retries if it can't find it. However they're failing in Selenium which attacks the problem immediately and doesn't do any retries.

Scenario: submit a question to the panel from its homepage
  When I submit the question "what's the best grease to use on my trucks?"
  Then I should be on the "Ruderiders" panel homepage
  And I should see the question entitled "what's the best grease to use on my trucks?" at the top of the feed
  • works in Capybara
  • fails in Selenium (@javascript

How can I force Selenium to do the same wait and retry that Capybara does?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

简单 2024-12-06 23:10:28

您应该检查您的 Capybara.default_wait_time 设置,并根据需要增加默认等待时间。

我很高兴它对你有用:)

You should check your Capybara.default_wait_time setting and increase the default wait time if needed.

I am glad it worked for you :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文