WebDriverManager 5: Automated driver management and Docker builder for Selenium WebDriver

Boni García
3 min readSep 13, 2021

WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers required by Selenium WebDriver (e.g., chromedriver, geckodriver, msedgedriver, etc.) in a fully automated manner.

WebDriverManager enables the development of portable WebDriver tests while reducing the development and maintenance efforts. For instance, the skeleton of a JUnit 5 test using Selenium WebDriver and WebDriverManager is as follows:

WebDriverManager implements a resolution algorithm for automated driver management. The foundations of this algorithm are:

  1. Browser version discovery.
  2. Driver version match.
  3. Driver and resolution cache.
  4. Export driver path as system property setup.

You can find all the internal details of this resolution algorithm in the paper Automated driver management for Selenium WebDriver, published in the Springer Journal of Empirical Software Engineering in 2021.

WebDriverManager 5: the next generation

WebDriverManager was first released in 2015. Nowadays, it is a well-known helper library for Selenium WebDriver, used in thousands of projects. WebDriverManager 5 was released in 2021. As usual, this release allows the automated driver management for Selenium WebDriver. Moreover, this release provides other features aimed to ease the development of Selenium WebDriver tests.

New documentation

The documentation has been completely rewritten in WebDriverManager 5:

https://bonigarcia.dev/webdrivermanager/

Internally, this site is done in AsciiDoc, and it is generated to HTML, PDF, and EPUB.

Browser finder

As of version 5, WebDriverManager allows detecting if a given browser is installed or not in the local system. To this aim, each manager provides the method getBrowserPath(). This method returns an Optional<Path>, which is empty if a given browser is not installed in the system or the browser path (within the optional object) when detected. You can use this feature to skip tests using assumptions, for instance, as follows:

WebDriver builder

WebDriverManager 5 also allows instantiating WebDriver objects (e.g., ChromeDriver, FirefoxDriver, etc.) using the WebDriverManager API. This feature is available using the method create() of each manager. For instance:

Browsers in Docker

Another relevant new feature available in WebDriverManager 5 is the ability to create browsers in Docker containers out of the box. To use it, we need to invoke the method browserInDocker() in conjunction with create() of a given manager. For instance:

The used Docker images by Selenium-Jupiter have been created and maintained by Aerokube. Therefore, Chrome (desktop and mobile), Firefox, Edge, Opera, and Safari (WebKit engine) are the available browsers to be executed as Docker containers in WebDriverManager. In addition, we can use the beta and development versions of Chrome and Firefox, thanks to a fork of the Aerokube images maintained by Twilio.

WebDriverManager allows connecting to the remote desktop session simply invoking the method enableVnc() of a dockerized browser. In addition, we can use the method enableRecording() to record the browser session.

Other usages

WebDriverManager can be used as a CLI tool, Java agent, or Selenium Server. Take a look at the documentation for further details:

https://bonigarcia.dev/webdrivermanager/

Selenium-Jupiter

WebDriverManager is the foundation tool of Selenium-Jupiter, an open-source JUnit 5 extension for developing Selenium WebDriver tests. Thanks to the parameter resolution provided by JUnit 5, the required boilerplate of a WebDriver test is reduced to the minimum.

Selenium-Jupiter also provides seamless integration with Docker, recordings, VNC, and more. Check out the documentation for the complete reference and examples:

https://bonigarcia.dev/selenium-jupiter

--

--

Boni García

Visiting Professor at Universidad Carlos III de Madrid (UC3M), Spain. Creator of WebDriverManager and Selenium-Jupiter.