DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Running PyTorch on GPUs
  • How You Can Avoid a CrowdStrike Fiasco
  • Maximizing Laravel's Potential: A Guide to Driver-Based Services
  • What Are the Key Applications and Benefits of IoT Fleet Management?

Trending

  • Intro to RAG: Foundations of Retrieval Augmented Generation, Part 1
  • Building Enterprise-Ready Landing Zones: Beyond the Initial Setup
  • Transforming AI-Driven Data Analytics with DeepSeek: A New Era of Intelligent Insights
  • Unmasking Entity-Based Data Masking: Best Practices 2025

WebDriverManager: How to Manage Browser Drivers Easily and Efficiently

In this post, we check out a cool open source web dev project from the world of GitHub that makes managing browser drivers easier.

By 
Arunkumar Velusamy user avatar
Arunkumar Velusamy
·
Oct. 23, 18 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
34.0K Views

Join the DZone community and get the full member experience.

Join For Free

We all know that we need to have browser drivers, .exe files like chromedriver.exe and geckodriver.exe in case of windows environment or binary files like chromedriver and geckodriver in case of Linux distributions, which allows Selenium WebDriver to handle browsers in order to run our selenium webdriver automation scripts on Chrome and Firefox browsers (applicable for other browsers as well).

And, also, we need to set the path of these files in our script, like below, or we need to add the location to the classpath.

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

If the path is not defined or if the path provided is wrong, we will get an exception like below when running our tests.

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:847)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:125)
at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:43)
at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:168)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:346)
at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:168)
at org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:125)

WebDriverManager by Boni Garcia helps us to manage driver related settings with ease. WebDriverManager gets the browser version and downloads relevant binaries/executables in an automated way; This helps us to avoid all the manual steps that we previously had to do, related to browser driver setup, in order to run our tests.

It supports browsers such as Chrome, Firefox, Opera, PhantomJS, Microsoft Edge, or Internet Explorer. You can these specs and more on the project page.

All we have to do is to add its dependency through Maven or Gradle to download all the necessary drivers. Note that drivers will be downloaded only if the same version driver is not present on the WebDriverManager cache (~/.m2/repository/webdriver by default) by eliminating frequent downloads. You can update this default location using the properties file.

In the case of a Maven project, we need to add the following dependency in pom.xml.

<dependency>
   <groupId>io.github.bonigarcia</groupId>
   <artifactId>webdrivermanager</artifactId>
   <version>3.0.0</version>
</dependency>

Check the Maven page for more details about supported builder projects.

Sample Code:

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

import io.github.bonigarcia.wdm.WebDriverManager;

public class WebDriverManagerTest {
 public static void main(String[] args) {
  new WebDriverManagerTest().testDriverManagerChrome();
  new WebDriverManagerTest().testDriverManagerFirefox();
 }

 public void testDriverManagerChrome() {
  WebDriverManager.chromedriver().setup();
  WebDriver driver = new ChromeDriver();
  driver.get("http://www.google.com/");
  System.out.println(driver.getTitle());
  driver.quit();
 }

 public void testDriverManagerFirefox() {
  WebDriverManager.firefoxdriver().setup();
  WebDriver driver = new FirefoxDriver();
  driver.get("http://www.google.com/");
  System.out.println(driver.getTitle());
  driver.quit();
 }
}

Article source - AllSelenium.info

Driver (software)

Published at DZone with permission of Arunkumar Velusamy. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Running PyTorch on GPUs
  • How You Can Avoid a CrowdStrike Fiasco
  • Maximizing Laravel's Potential: A Guide to Driver-Based Services
  • What Are the Key Applications and Benefits of IoT Fleet Management?

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: