WebDriverManager : No more driver.exe in Selenium

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

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

System.setProperty("webdriver.chrome.driver", "/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("webdriver.ie.driver", "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 can be used in 3 different ways:


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 can be used in 3 different ways:

WebDriverManager as Java dependency

In order 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):

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.6.1</version>
    <scope>test</scope>
</dependency>

Example:

public class ChromeTest {
private WebDriver driver;

@BeforeClass
public static void setupClass() {
    WebDriverManager.chromedriver().setup();
}

@Before
public void setupTest() {
    driver = new ChromeDriver();
}

@After
public void teardown() {
    if (driver != null) {
        driver.quit();
    }
}

@Test
public void test() {
    // Your test code here
}
}

Source: https://github.com/bonigarcia/webdrivermanager/

Leave a Reply