DEV Community

Arvind Choudhary
Arvind Choudhary

Posted on

Getting started with WDM(WebDriverManager)

Hello Readers,

Whenever we talk about Automation Testing(Browser Automation) we should have a few things in place:

  1. Browser (Should be on the system path).
  2. Driver Executable (Should be on the system path), Driver Executable version should be the same as Browser Version.
  3. Automation Library(In our case Selenium).

The second part of Point 2 is tedious. Nowadays we get at least one browser update every month or two, so we have to download the driver executable which is released for that particular browser version.


Chrome release channel information - source:wikipedia

As shown in fig, chrome releases multiple browsers update each month in stable/beta/developer channels.


So, How can we make our test project in such a way that there should be no manual intervention required in getting the correct driver executables for different browsers?

WDM(WebDriverManager) utility which is created by bonigarcia could help us in automatically downloading driver version based on different browsers, browser version and OS's .


WebDriverManager

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. In addition, as of version 5, WebDriverManager provides other relevant features, such as the capability to discover browsers installed in the local system, building WebDriver objects (such as ChromeDriver, FirefoxDriver, EdgeDriver, etc.), and running browsers in Docker containers seamlessly.


Maven dependency:

<dependency>
 <groupId>io.github.bonigarcia</groupId>
 <artifactId>webdrivermanager</artifactId>
 <version>5.1.1</version>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Pom.xml:

minimal pom.xml dependency list for browser automation with WDM and selenium.

pom.xml

Script (java):

Iโ€™ve used java language to use with selenium.
script


Examples of how to set up driver executable for different browsers.
WebDriverManager.chromedriver().setup();
WebDriverManager.edgedriver().setup();
WebDriverManager.firefoxdriver().setup();
How to specify which driver executable we want (Explicit specification, Optional)
WebDriverManager.firefoxdriver().browserVersion("100").setup();


Console print:

Console print


Useful URL's

bonigarcia's github page

WebDriverManager website

WebDriverManager repository

Top comments (0)