Auto download Driver Executables using WebDriverManager - H Y R Tutorials

Auto download Driver Executables using WebDriverManager

Share This
In this video, I have explained how we can use webdrivermanager and auto-download the driver executables into our local system.

WebDriverManager allows automating the management of the binary drivers (e.g. chromedriver, geckodriver, etc.) required by Selenium WebDriver.

If you use Selenium WebDriver, you probably know that to use some browsers such as Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, or Internet Explorer, first you need to download the so-called driver, i.e. a binary file which allows WebDriver to handle browsers. In Java, the path to this driver must be set as JVM properties, as follows:

System.setProperty("", "/path/to/binary/chromedriver");
System.setProperty("webdriver.gecko.driver", "/path/to/binary/geckodriver");
System.setProperty("webdriver.opera.driver", "/path/to/binary/operadriver");
System.setProperty("phantomjs.binary.path", "/path/to/binary/phantomjs");
System.setProperty("webdriver.edge.driver", "C:/path/to/binary/msedgedriver.exe");
System.setProperty("", "C:/path/to/binary/IEDriverServer.exe");

This is quite annoying since it forces you to link directly this binary file into your source code. In addition, you have to check manually when new versions of the binaries are released. WebDriverManager comes to the rescue, performing in an automated way all this dirty job for you.

WebDriverManager is open-source, released under the terms of Apache 2.0 License.

To use WebDriverManager from tests in a Maven project, you need to add the following dependency in your pom.xml (Java 8 or upper required):


... or in Gradle project:

dependencies {

public class ChromeTest {
    private WebDriver driver;

    public static void setupClass() {
        driver = new ChromeDriver();

Notice that simply adding WebDriverManager.chromedriver().setup(); WebDriverManager does magic for you:

  • It checks the version of the browser installed in your machine (e.g. Chrome, Firefox).
  • It checks the version of the driver (e.g. chromedriver, geckodriver). If unknown, it uses the latest version of the driver.
  • It downloads the WebDriver binary if it is not present on the WebDriverManager cache (~/.m2/repository/webdriver by default).
  • It exports the proper WebDriver Java environment variables required by Selenium

WebDriverManager resolves the driver binaries for the browsers Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, Internet Explorer, and Chromium. For that, it provides several drivers managers for these browsers. These drivers managers can be used as follows: