【问题标题】:Feature Testing with Filepicker.io and Capybara使用 Filepicker.io 和 Capybara 进行功能测试
【发布时间】:2013-04-09 04:36:22
【问题描述】:

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

【问题讨论】:

  • 我能够遵循本指南mscottford.com/post/30910962407/…,并使用 Poltergeist 进行远程调试。进一步检查页面后,我可以看到 Filepicker 界面和 iframe 没有打开,但是没有给出控制台错误。

标签: ruby rspec capybara filepicker.io poltergeist


【解决方案1】:

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

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

因为默认超时是 30

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 注意到这一点并更新了代码,但我现在确定真正的问题是框架永远不会加载或添加到 DOM。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多