Capybara webkit无效响应错误,如何调试? [英] Capybara webkit invalid response error, how to debug?

查看:89
本文介绍了Capybara webkit无效响应错误,如何调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写网页的请求规范。

I'm trying to write a request spec for a web page.

此页面在开发中没有错误。

This page works in development without error.

但是在capybara webkit中运行时,尝试提交表单后出现此错误:

But running in capybara webkit I get this error after trying to submit the form:

 Failure/Error: Unable to find matching line from backtrace
 Capybara::Driver::Webkit::WebkitInvalidResponseError:
   Unable to load URL: https://127.0.0.1:33416/sign_in

为了找出原因,我开始剥离页面上的标记和JavaScript 。直到它是一个带有普通提交按钮的空表单。我仍然遇到上述错误!

In an effort to find out the cause I've started stripping out markup and JavaScript on the page. To the point where it is an empty form with a plain submit button. I still get the above error!

现在的测试实际上是:

it "should be able create a new foo", :js, :focus do
  visit new_foo_path
  find('#submit').click
end

但是,如果我删除了:js选项,则此测试有效:

This test does however work if I remove the :js option:

it "should be able create a new foo", :focus do
  visit new_foo_path
  find('#submit').click
end

JavaScript测试确实可以在此应用程序的其他页面上工作...

Javascript tests do work in other pages on this application...

这对我来说毫无意义。有人对如何从此处进行调试有任何建议吗?

This is making no sense to me. Does anyone have any suggestions how to debug from here?

感谢您的帮助

推荐答案

您看到的错误很可能是capybara-webkit告诉您页面中存在某种异常的一种神秘方式。我前段时间有相同的问题,还有无法加载URL的问题

The error you're seeing is most likely capybara-webkit's cryptic way of telling you that there is some sort of exception in the page. I had the same problem a while back, and the "Unable to load URL" thing totally threw me off, making it hard to find the actual problem.

尝试一些尝试时,我建议:

As a few things to try, I'd suggest:


  • 确保已安装最新版本的capybara-webkit。

  • 检查测试元素(而不是实际形式),例如控制器逻辑以及所涉及的任何模型。清除所有内容,直到没有任何内容为止。

  • 查看讨论在此问题上,并从那里跟踪线索。我很确定这是相同的问题或相关的问题。

  • Make sure you have the latest version of capybara-webkit installed.
  • Check elements of the test other than the actual form, e.g. the controller logic and any models that are involved. Strip everything out until you have nothing.
  • Check out the discussion on this issue and follow leads from there. I'm pretty sure it's the same problem or a related one.

祝你好运!

这篇关于Capybara webkit无效响应错误,如何调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆