Browser drivers management with WebDriverManager

The Blog To Learn Selenium and Test Automation

Browser drivers management with WebDriverManager

In this article, we are going to leverage WebDriverManager by Boni Garcia to setup browser drivers required to execute our tests.

We all know that we need to have browser drivers, .exe files like chromedriver.exe and geckodriver.exe in case of windows environment or binary files like chromedriver and geckodriver in case of linux distributions, in order to run our selenium webdriver automation scripts on chrome and firefox browsers.

And also we need to set the path of these files in our script like below or we need to add location to the class path.

Example for chrome browser

System.setProperty("", "/path/to/binary/chromedriver");

Example for firefox browser:

System.setProperty("webdriver.gecko.driver", "/path/to/binary/geckodriver");

If the path is not defined or if the path provided is wrong, we will get an exception like below when running our tests.

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see The latest version can be downloaded from
	at org.openqa.selenium.remote.service.DriverService.findExecutable(
	at org.openqa.selenium.firefox.GeckoDriverService.access$100(
	at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(
	at org.openqa.selenium.remote.service.DriverService$
	at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(
	at org.openqa.selenium.firefox.FirefoxDriver.(
	at org.openqa.selenium.firefox.FirefoxDriver.(

To avoid this error, we need to manually download and manage these drivers for each operating systems/environments and that is very painful. We also have to check and update relevant drivers when new versions of the binaries are released or new browsers versions are released along with compatibility for driver to browser.

WebDriverManager by Boni Garcia helps us to manage driver related settings automatically. Webdriver manager downloads binaries/executables in an automated way and helps us to avoid all the manual steps that we do previously related to browser drivers to run our tests.

It supports browsers such as Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, or Internet Explorer. You can check that in project page.

All we have to do is to add its dependency through Maven or Gradle to download all the necessary drivers. Note that drivers will be downloaded only if they are not present on the WebDriverManager cache (~/.m2/repository/webdriver by default). You can update this default location using properties file

In case of Maven project, we need to add the following dependency in pom.xml :-


For Gradle project:

dependencies {

You can also download this jar file and its dependencies to add as external jars in case if your project is not a maven project.

Check maven page for more details of supported builder projects.

Example for launching chrome and firefox browser

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class WebDriverManagerTest {
	public static void main(String[] args) {
		new WebDriverManagerTest().testDriverManagerChrome();
		new WebDriverManagerTest().testDriverManagerFirefox();
	public void testDriverManagerChrome() {
		WebDriver driver = new ChromeDriver();
	public void testDriverManagerFirefox(){
		WebDriver driver = new FirefoxDriver();

Webdrivermanager, by default, tries to download the latest version of a given browser driver binary. To use a specific version of driver, pass the driver version like below


To download specific versions or from specific urls, change respective value of the variables in or depending on where it is available.
Also you can add support to any new versions of browser driver by defining it in

Have a look at
Have a look at

At any time you want to change default values, copy the required files from here into your resources directory with exact same name and update required values in the property file. That’s it.

This eliminates lot of manual works and incompatibility issues. Thanks to Boni Garcia. Happy scripting!!!

Don’t forget to provide your valuable comments.


Leave a Reply

Your email address will not be published. Required fields are marked *