1

我目前正在对 Filepicker.io 上传表单进行功能测试,但无法让文件上传正常工作。我正在为 Capybara 使用Poltergeist驱动程序,并且从我能够进行的调试中,Filepicker iframe 永远不会加载。我已经通过使用 Poltergeist 的远程调试确认了这一点。

这是测试代码的示例:

within_fieldset 'Photos' do
  click_button 'Find Photo'
end
within_frame 'filepicker_dialog' do
  attach_file '#fileUploadInput', Rails.root.join('spec', 'files', 'photo.jpg')
end

并产生错误:

Failure/Error: within_frame '#filepicker_dialog' do
 Capybara::Poltergeist::TimeoutError:
   Timed out waiting for response to {"name":"push_frame","args":["#filepicker_dialog"]}. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Poltergeist :timeout option to a higher value will help (see the docs for details). If increasing the timeout does not help, this is probably a bug in Poltergeist - please report it to the issue tracker.

尝试通过 javascript 控制台手动触发 Filepicker 也不会产生任何结果。

4

2 回答 2

1

你试过增加超时吗?

Capybara.javascript_driver = :poltergeist
Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, {:timeout => 50})
end

因为默认超时是 30

于 2013-11-13T15:11:53.510 回答
0

Capybara APIwithin_frame有点奇怪。它需要一个框架名称,而不是框架的 CSS 选择器。所以 Poltergeist 正在寻找一个名为“#filepicker_dialog”的框架——我怀疑这是你的问题。

于 2013-04-09T19:04:06.230 回答