增加 poltergeist 的超时时间

Increasing timeout of poltergeist

我需要增加 Poltergeist 中的超时时间。 poltergeist 文档说我需要将此代码放入我的测试设置中

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, options)
end

我是测试新手,我不确定测试设置在哪里。 我正在使用 Rpsec 和水豚。有人可以帮忙吗?

这应该有效:

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, timeout: 1.minute)
end

你有长 运行宁 javascript 或 ajax 吗?

https://coderwall.com/p/aklybw/wait-for-ajax-with-capybara-2-0 and http://robots.thoughtbot.com/automatically-wait-for-ajax-with-capybara - 如何处理ajax

还有一种方法可以在测试中禁用动画,以使其 运行 更快。如果你有一些带有 position: fixed 的元素,那么 poltergeist 会看到它后面的文本是不可见的。