Capybara-webkit tries to open example.com

北慕城南 提交于 2019-12-03 10:40:12

Try using visit products_path instead. They do not recommend using absolute URLs in "Gotchas" section of README.

For me, there was a much sneaker "gotcha" (and I was using Capybara with Rspec). Originally in a spec I had:

visit "foos/5"

This worked fine with Rack::Test but when I wanted to switch to the webkit driver to test js interactions, I got that exception (Unable to load URL: file:///products (Capybara::Driver::Webkit::WebkitInvalidResponseError)).

What I had to do was change the path I passed to visit, like so:

visit "/foos/5"

Succes!!

Here's another potential gotcha, posted for others that might have this issue. I was testing action caching, and the key Rails generates looks like "views/www.example.com/products". This happens even if you use products_path as the url. This can lead to the need to set your server name so you can know in advance what cache key to expect.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!