Manage driver executables using webdrivermanager

In order to run our selenium webdriver automation scripts on chrome/firefox browsers, we have to download the binary/.exe files like Chromedriver.exe and geckodriver.exe.

And also we need to set the path of these files in our script like below or its location should be added to the classpath. Earlier we have seen examples to launch browsers like Chrome, Firefox and Edge browser

For chrome browser :-

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

For firefox browser :-

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

If the path is not defined or if we provide the wrong path, you will see an exception like below :-

Error: The path to the driver executable must be set by the system property

Manually downloading and managing these drivers for each operating systems is very painful. We also have to check when new versions of the binaries are released / new browsers versions are released. We should check the compatibility for all the executables and add it.

Have you ever thought of downloading all the driver executables automatically ???

Yes. WebDriverManager by Boni Garcia does this. Webdrivermanager helps to download binanries/executables in an automated way. It supports browsers such as Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, or Internet Explorer.

We just need to add its dependency through Maven or Gradle to download all the necessary drivers. It will download ONLY if they are not present on the WebDriverManager cache (~/.m2/repository/webdriver by default).

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


For Gradle project:

dependencies {

How to use Webdrivermanager to launch chrome/Firefox browser in Selenium WebDriver ?

let us look at below example to launch chrome browser :-

package com.tests;

import org.openqa.selenium.WebDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import io.github.bonigarcia.wdm.WebDriverManager;

public class ExampleTest {

	private WebDriver driver;
	public void setUp() {
		driver = new ChromeDriver();
	public void Seleniumtest1() {
		System.out.println("In test 1");
		String expectedPageTitle = "Google";
		Assert.assertTrue(driver.getTitle().contains(expectedPageTitle), "Test Failed");
	public void Seleniumtest2() {
		System.out.println("In test 2");
	public void Seleniumtest3() {
		System.out.println("In test 3");

	public void tearDown() {

When we use webdrivermanager, By default, it tries to download the latest version of a given driver binary. if you want to use a specific version of driver, we can do that by using WebDriverManager.chromedriver().version("2.40").setup();

You can force WebDriverManager to download specific versions by changing the value of the variables in for wdm.chromeDriverVersion, wdm.operaDriverVersion, wdm.internetExplorerDriverVersion, or wdm.edgeDriverVersion to a concrete version.

For instance:


If you require any further information, feel free to add your comment.

Thank You.

Selenium Tutorials: 


Have you tried on Linux? Will it work?
I did but it was not working.

what is the error message your are seeing ?

Was able to get the same example work on Mac.

Add new comment