Provides a method of automatically downloading WebDriver binaries.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib
spec
test
.gitignore
.hound.yml
.rspec
.rubocop.yml
.travis.yml
CODE_OF_CONDUCT.md
Gemfile
LICENSE.txt
README.md
Rakefile
webdriver_manager.gemspec

README.md

WebDriver Manager

Gem Version License

Dependency Status

The goal of WebDriver Manager is to allow automated testing solutions an ability to have WebDriver binary drivers downloaded automatically.

Installation

Add this line to your application's Gemfile:

gem 'webdriver_manager'

And then include it in your bundle:

$ bundle

You can also install WebDriver Manager just as you would any other gem:

$ gem install webdriver_manager

Usage

Basic Usage

Here is an example script:

require "webdriver_manager"
require "watir"

browser = Watir::Browser.new :firefox

browser.quit()

All you have to do is include webdriver_manager. Once it's included, the gem provides hooks into the operation of Selenium WebDriver. When Watir, in this case, is used to instantiate a new Firefox browser, this gem kicks in and makes sure that geckodriver (or geckodriver.exe on Windows) is available. If the driver binary is not available, it will be downloaded for you.

All driver binaries are placed in a .webdrivers directory within the relevant directory referred to by the HOME environment variable for your operating system.

Browser Drivers Supported

Currently WebDriver Manager supports Chrome (chromedriver), Firefox (geckodriver), Internet Explorer (IEDriverServer), and Edge (MicrosoftWebDriver). The support for Internet Explorer and Edge is a bit of a work in progress but, overall, they should work in terms of getting the appropriate driver.

Logging

You can enable logging with WebDriver Manager with a command like this:

WebDriverManager.logger.level = :debug

There are debug statements in the code base that will show you what's happening as WebDriver Manager operates. But you are free to add your own messages as well. For example, you could set the logging level to info and then add your own messages:

WebDriverManager.logger.level = :info
WebDriverManager.logger.info("Some Information")

You can also set the logging output to a file:

WebDriverManager.logger.output = 'webdriver_manager.log'

How It Works

WebDriver Manager works by providing an additional implementation to the @driver_path variable that Selenium uses when establishing an instance of a driver. For example, the Chrome implementation simply takes in a path for the driver. This gem overrides that with its own specific functionality for providing a standard path and making sure the relevant binaries are on that path and downloading them if not.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec:all to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run bundle exec rake install.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jeffnyman/webdriver_manager. The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another testing tool. As such, contributors are very much welcome but are expected to adhere to the Contributor Covenant code of conduct.

To contribute to WebDriver Manager:

  1. Fork the project.
  2. Create your feature branch. (git checkout -b my-new-feature)
  3. Commit your changes. (git commit -am 'new feature')
  4. Push the branch. (git push origin my-new-feature)
  5. Create a new pull request.

Author

Credits

There is a good Python project called webdriver_manager as well as a Java project WebDriverManager. This is my attempt to provide the same functionality in a Ruby context. I'm relying, as inspiration, on Titus Fortner's webdrivers project while trying to update some aspects of, including a cleanup of the overall code base.

License

WebDriver Manager is distributed under the MIT license. See the LICENSE file for details.