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



我目前正在对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也不会产生任何结果。

您是否尝试过增加超时时间?

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

默认超时时间为30

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

最新更新