Trying to get selenium working in rails 3 - "WebMock::NetConnectNotAllowedError" Trying to get selenium working in rails 3 - "WebMock::NetConnectNotAllowedError" selenium selenium

Trying to get selenium working in rails 3 - "WebMock::NetConnectNotAllowedError"


With this...

WebMock.disable_net_connect!(:allow_localhost => true)

you allow real web access to your localhost. It's perfect when you need to use Selenium for you application and, at the same time, mock external resources.


It's because you are using webmock. It blocks all outbound HTTP requests.

If you don't need it, remove it from the Gemfile. If you do need it, then you may need to configure it more precisely to your needs:

https://github.com/bblimke/webmock


We use this to enable normal requests in capybara, and allow selenium's callbacks everywhere, because they are fired after requests are finished.

# spec/spec_helper.rbRSpec.configure do |config|  config.before(:all, type: :request) do    WebMock.allow_net_connect!  end    config.after(:all, type: :request) do    selenium_requests = %r{/((__.+__)|(hub/session.*))$}    WebMock.disable_net_connect! :allow => selenium_requests  endend