相关疑难解决方法(0)

试图让selenium在rails 3中运行 - "WebMock :: NetConnectNotAllowedError"

我试图在rails 3 app中第一次使用selenium.(我之前用过rails 2).我在一个rvm当然有自己的宝石.

我首先用capybara运行了一个没有硒的任务:

#./spec/requests/homepage_spec.rb
require 'spec_helper'

describe 'home page', :type => :request do
  it 'should welcome the user' do
    visit '/'
    page.should have_content('Buddy')
  end
end
Run Code Online (Sandbox Code Playgroud)

这很好.然后我在describe的选项中添加了一个":js => true"选项,它应该使用selenium运行(据我所知).并得到这个错误:

 Failure/Error: @page.start_new_browser_session
 WebMock::NetConnectNotAllowedError:
   Real HTTP connections are disabled. Unregistered request: POST http://localhost:4444/selenium-server/driver/ with body 'cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Flocalhost%3A3000&3=&4=' with headers {'Accept'=>'*/*', 'Content-Type'=>'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent'=>'Ruby'}

   You can stub this request with the following snippet:

   stub_request(:post, "http://localhost:4444/selenium-server/driver/").
     with(:body => "cmd=getNewBrowserSession&1=%2Afirefox&2=http%3A%2F%2Flocalhost%3A3000&3=&4=", 
          :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/x-www-form-urlencoded; charset=utf-8', 'User-Agent'=>'Ruby'}).
     to_return(:status => 200, :body => "", :headers => {}) …
Run Code Online (Sandbox Code Playgroud)

selenium capybara ruby-on-rails-3

32
推荐指数
5
解决办法
2万
查看次数

标签 统计

capybara ×1

ruby-on-rails-3 ×1

selenium ×1