How to Automate The Management of Web Drivers?

Yusuf Tayman
3 min readNov 7, 2020

Test engineers or people dealing with automation know very well. When we use Selenium Webdriver, we need to download the drivers and check the version of which browser we will use.

In some cases, we may need to change the drivers according to the browser versions, so when you work in the local environment when the driver version in your project does not match the driver version in your local, you need to find and update the same version over and over again.

You do not have to deal with them anymore, at this point, WebDriverManager provides you a great benefit.

Let’s move on to how to configure this magic touch. First of all, we need to add the following dependency to your Maven project.

<! — https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.2.2</version>
</dependency>

Now let’s see how it can be used with a very simple test.

As you can see, the installation is very simple before setting the driver or options, with just one line, the WebDriverManager uses the version of the browser on your computer for you. If it cannot detect the version, it is using the latest version. You can use all these not only for Chrome but also for all other browsers.

WebDriverManager.chromedriver().setup();
WebDriverManager.firefoxdriver().setup();
WebDriverManager.edgedriver().setup();
WebDriverManager.operadriver().setup();
WebDriverManager.phantomjs().setup();
WebDriverManager.iedriver().setup();
WebDriverManager.chromiumdriver().setup();

Of course, it is not limited to these, you can easily perform your test with different versions of browsers in a single project as follows. My local now has chrome 86 version installed, now let’s run our test using version 85. In order to do this, we enter that value in our function with the driverVersion command in which version we will run our test.

You can use it with both uses as above. You no longer need to constantly deal with driver installations. This way you can automate to web drivers. 😜

--

--