Poltergeist无法连接到服务器。下面是我得到的错误:使用路径助手时,水豚Poltergeist被迫通过https
Failure/Error: visit root_path
Capybara::Poltergeist::StatusFailError:
Request to 'http://127.0.0.1:58638/' failed to reach server, check DNS and/or server status
我已经上了phantomjs调试输出,这里是什么样子的相关线路对我说:
2016-12-14T14:24:47 [DEBUG] WebpageCallbacks - getJsConfirmCallback
{"command_id":"5eab3091-26bd-47b7-b779-95ec9523fb5b","response":true}
{"id":"1069af41-1b7c-4f5b-a9c7-258185aa8c73","name":"visit","args":["http://127.0.0.1:58638/"]}
2016-12-14T14:24:47 [DEBUG] WebPage - updateLoadingProgress: 10
2016-12-14T14:24:48 [DEBUG] Network - Resource request error: QNetworkReply::NetworkError(ConnectionRefusedError) ("Connection refused") URL: "https://127.0.0.1/"
2016-12-14T14:24:48 [DEBUG] WebPage - updateLoadingProgress: 100
2016-12-14T14:24:48 [DEBUG] WebPage - setupFrame ""
2016-12-14T14:24:48 [DEBUG] WebPage - setupFrame ""
2016-12-14T14:24:48 [DEBUG] WebPage - evaluateJavaScript "(function() { return (function() {\n return typeof __poltergeist;\n })(); })()"
2016-12-14T14:24:48 [DEBUG] WebPage - evaluateJavaScript result QVariant(QString, "undefined")
{"command_id":"1069af41-1b7c-4f5b-a9c7-258185aa8c73","error":{"name":"Poltergeist.StatusFailError","args":["http://127.0.0.1:58638/",null]}}
{"id":"cbe42cdc-58db-49c5-a230-4a1f4634d830","name":"reset","args":[]}
这一点似乎是一个线索Network - Resource request error: QNetworkReply::NetworkError(ConnectionRefusedError) ("Connection refused") URL: "https://127.0.0.1/"
并且它可能是一个ssl错误,所以我添加了phantomjs选项--ignore-ssl-errors=true
,但它对响应没有任何影响。
我切换到capybara-webkit
看看是否会提供更多的信息,因为有些人推荐。我得到一个非常类似的错误:
"Visit(http://127.0.0.1:64341/)" started page load
Started request to "http://127.0.0.1:64341/"
Finished "Visit(http://127.0.0.1:64341/)" with response "Success()"
Started request to "https://127.0.0.1/"
Received 301 from "http://127.0.0.1:64341/"
Received 0 from "https://127.0.0.1/"
Page finished with false
Load finished
Page load from command finished
Wrote response false "{"class":"InvalidResponseError","message":"Unable to load URL: http://127.0.0.1:64341/ because of error loading https://127.0.0.1/: Unknown error"}"
Received "Reset()"
Started "Reset()"
undefined|0|SECURITY_ERR: DOM Exception 18: An attempt was made to break through the security policy of the user agent.
与托马斯 - 沃波尔@帮助我意识到,如果我具体的非HTTPS URL中水豚考察,它的工作原理。例如visit "http://localhost:3000"
它的工作原理。使用visit root_url
的作品,但使用visit root_path
我被定向到https和上面的错误。
config.force_ssl
不正确。我在config/environments/test.rb
中设置了config.force_ssl = false
,并且在测试环境中也使用pry来检查Application.config
。
任何想法为什么通过https发送路径助手将不胜感激。
如果相关,我可以在命令行上使用phantomjs连接'http://127.0.0.1:3000 /'。 – equivalentideas