Webdrivers

Gem Version Build status

Run Selenium tests more easily with automatic installation and updates for all supported webdrivers.

Description

webdrivers downloads drivers and directs Selenium to use them. Currently supports:

Usage

In your Gemfile:

gem 'webdrivers', '~> 3.0'

In your project:

require 'webdrivers'

The drivers will now be automatically downloaded or updated when you launch a browser through Selenium.

Download Location

The default download location is ~/.webdrivers directory, and this is configurable:

 Webdrivers.install_dir = '/webdrivers/install/dir'

Version Pinning

If you would like to use a specific (older or beta) version, you can specify it for each driver. Otherwise, the latest (stable) driver will be downloaded and passed to Selenium.

# Chrome
Webdrivers::Chromedriver.version = '2.46'

# Firefox
Webdrivers::Geckodriver.version  = '0.23.0'

# Microsoft Internet Explorer
Webdrivers::IEdriver.version     = '3.14.0'

# Microsoft Edge
Webdrivers::MSWebdriver.version  = '17134'

You can also trigger the update in your code, but it is not required:

Webdrivers::Chromedriver.update

Proxy

If there is a proxy between you and the Internet then you will need to configure the gem to use the proxy. You can do this by calling the configure method.

Webdrivers.configure do |config|
  config.proxy_addr = 'myproxy_address.com'
  config.proxy_port = '8080'
  config.proxy_user = 'username'
  config.proxy_pass = 'password'
end

SSL_connect errors

If you are getting an error like this (especially common on Windows):

SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Add the following to your Gemfile:

gem "net_http_ssl_fix"

Add the following to your code:

require 'net_http_ssl_fix'

Other solutions are documented on the RubyGems website.

Logging

The logging level can be configured for debugging purpose:

Webdrivers.logger.level = :DEBUG

Browser Specific Notes

When using Chrome/Chromium

The version of chromedriver will depend on the version of Chrome you are using it with:

  • For versions >= 70, the downloaded version of chromedriver will match the installed version of Google Chrome. More information here.
  • For versions <= 69, chromedriver version 2.46 will be downloaded.
  • For beta versions, you'll have to set the desired beta version of chromedriver using Webdrivers::Chromedriver.version.

The gem, by default, looks for the Google Chrome version. You can override this by providing a path to the Chromium binary:

Selenium::WebDriver::Chrome.path = '/chromium/install/path/to/binary'

This is also required if Google Chrome is not installed in its default location.

When using Microsoft Edge

After updating Microsoft Edge on Windows 10, you will need to delete the existing binary (%USERPROFILE%/.webdrivers/MicrosoftWebDriver.exe) to to be able to download the latest version through this gem.

This is because MicrosoftWebDriver.exe is not backwards compatible and it does not have an argument to retrieve the current version. We work around this limitation by querying the current Edge version from the registry and fetching the corresponding binary IF a file does not already exist. If a file does exist, the gem assumes it is the expected version and skips the download process.

If you continue with the outdated binary, Selenium will throw an error: unable to connect to MicrosoftWebDriver localhost:17556.

Wiki

Please see the wiki for solutions to commonly reported issues.

License

The gem is available as open source under the terms of the MIT License, see LICENSE.txt for full details and copyright.

Contributing

Bug reports and pull requests are welcome on GitHub. Run bundle exec rake and squash the commits in your PRs.

Copyright (c) 2017 Titus Fortner See LICENSE for details