使用Filepicker.io和Capybara进行功能测试

时间:2013-04-09 04:36:23

标签: ruby rspec capybara filepicker.io poltergeist

我目前正在开发功能测试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也不会产生任何结果。

2 个答案:

答案 0 :(得分:1)

你试过增加超时吗?

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

默认超时为30

答案 1 :(得分:0)

within_frame的Capybara API有点奇怪。它需要一个框架 name ,而不是框架的CSS选择器。因此,Poltergeist正在寻找名为“#filepicker_dialog”的框架 - 我怀疑这是你的问题。