2013-04-09 64 views
1

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

下面是测试代码的示例:

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也产生任何结果。

+0

我能够按照本指南,http://mscottford.com/post/30910962407/getting-spooky-remote-debugging-with-poltergeist-on,并使用Poltergeist进行远程调试。在进一步检查页面时,我可以看到Filepicker接口和iframe未打开,但没有给出控制台错误。 – Adam 2013-04-09 21:52:10

回答

0

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

+0

注意到这一点并更新了代码,但我现在确定了真正的问题是该框架永远不会加载或添加到DOM。 – Adam 2013-04-09 21:56:09

1

您是否试图增加超时时间?

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

为默认的超时时间为30