Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

WebDriverManager – Get Rid Of Compatability Issues Between Browser And Drivers

Posted on 03/16/2025 By admin

While automating a Web-based application using Selenium WebDriver, we must have faced the below issues:-

  1. Unable to create session due to outdated browser driver executable.
  2. maintaining the same browser version across the team so that your framework can run scripts.
  3. compatibility issues between currently installed browser and available driver executable in the framework
  4. managing browsers on the different operating system

Earlier I remember that we used to disable auto-update of browser to make our scripts stable. Nowadays browsers keep updating and we can not restrict our application to run on a specific version of the browser.

All these issues we can solve using a library called WebDriverManager and focus more on covering functionalities rather than spending much time on these browser’s compatibilities issues.

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

In Selenium WebDriver, you might aware that you need to explicitly download the compatible browser’s driver executable binary file and set the JVM path or properties so that selenium commands can be executed. These browser driver executables work as a bridge between your selenium commands/codes and browser. Below lines of code will explain more about the above statement.

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");

We can auto manage the download of browser executable and setting up of path using WebDriverManager.

WebDriverManager is a Java library. So you can either download it or use it as a dependency in a Maven or Gradle project. I will use the latest maven dependency of WebDriverManager as below:-

  io.github.bonigarcia webdrivermanager 4.4.3

After adding the above dependency, you just need to replace System.setProperty() line as below.

If you want to launch chrome browser then use the below line of code –

WebDriverManager.chromedriver().setup();

A similar line of code for other browsers.

The above code from WebDriverManager does magic for you:-

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

In short, it downloads the compatible browser driver executable as per the currently installed browser on your system and stores it on your local itself and an environment path is set up.

package mse_webdrivermanager.autoManageExecutables;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import io.github.bonigarcia.wdm.WebDriverManager;

public class LaunchChromeUsingWDM {

        public static void main(String[] args) {
                // It will download compatible chrome executable for you
                WebDriverManager.chromedriver().setup();
                System.out.println("Browser executable path is set as :- "+System.getProperty("webdriver.chrome.driver"));
                WebDriver driver = new ChromeDriver();
                driver.get("https://www.google.com/");
                System.out.println("Title is "+driver.getTitle());
                driver.quit();          
        }
}
Browser executable path is set as :- C:\Users\amomahaj\.cache\selenium\chromedriver\win32\91.0.4472.101\chromedriver.exe
Starting ChromeDriver 91.0.4472.101 (af52a90bf87030dd1523486a1cd3ae25c5d76c9b-refs/branch-heads/4472@{#1462}) on port 18868
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Jun 28, 2021 5:40:57 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Jun 28, 2021 5:40:58 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 91
Title is Google

Observer above output. It has download chromedriver 91.0.4472.101 after checking the installed version of chrome on my system. The below images will change in the future based on newer versions. This is the magic done by WebDriverManager.

It will download only if the compatible browser executable is not available in the cache. You can see in the above output how well organized it keeps the chromedrivers.

You can clone the git repo consisting above examples from here.

You can subscribe to my YouTube channel RetargetCommon to learn from video tutorials.

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyLearning

Uncategorized

Post navigation

Previous Post: Postman Tutorial Part 25 – Collection Runner in Postman
Next Post: Frequently Asked Java Program 08: Program to find occurrence of individual characters in a given string.

Related Posts

API Testing – Postman Uncategorized
REST Assured Tutorial 64 – How to pass value from one API to Another API using TestNG – ITestContext Uncategorized
image – Make Selenium Easy Uncategorized
Postman Tutorial Part 15 – Adding Automation Test Scripts In Postman Uncategorized
TOI – Make Selenium Easy Uncategorized
Hierarchy of Selenium Classes and Interfaces – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark