Skip to content

Using with VCR or WebMock

Lakshya Kapoor edited this page Apr 11, 2019 · 5 revisions

You may get this error when using webdrivers with VCR or WebMock gem:

Selenium::WebDriver::Error::WebDriverError: unable to connect to chromedriver

This is because the request to download the drivers is being blocked by them. Add the following download URLs to the list of ignore_hosts or allowed_sites to unblock them:

  • Chromedriver - chromedriver.storage.googleapis.com
  • Geckodriver - github.com/mozilla/geckodriver/releases
  • IEDriverServer - selenium-release.storage.googleapis.com
  • MicrosoftWebDriver - developer.microsoft.com/en-us/microsoft-edge/tools/webdriver

VCR

VCR.configure do |config|
  config.ignore_hosts(
    "chromedriver.storage.googleapis.com",
    "github.com/mozilla/geckodriver/releases",
    "selenium-release.storage.googleapis.com",
    "developer.microsoft.com/en-us/microsoft-edge/tools/webdriver"
  )
end

WebMock

allowed_sites = [
  "https://chromedriver.storage.googleapis.com",
  "https://github.com/mozilla/geckodriver/releases",
  "https://selenium-release.storage.googleapis.com",
  "https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver"
]

WebMock.disable_net_connect!(allow_localhost: true, allow: allowed_sites)

Sources

https://github.com/titusfortner/webdrivers/issues/57 https://github.com/titusfortner/webdrivers/issues/66

You can’t perform that action at this time.