Software Development and QA Tips By QASource Experts

What is WedDriver Manager and How to Update in Selenium

Written by QASource Engineering Team | Apr 15, 2024 4:00:00 PM

WebDriverManager is a third-party Java library that simplifies the management of browser drivers required by Selenium WebDriver. It automates the process of downloading the appropriate browser driver binaries, such as ChromeDriver and GeckoDriver, based on your operating system and browser version. This eliminates the need for manual downloads and the hassle of managing different driver versions for various browsers.

To update WebDriverManager in a Selenium project, you can follow these steps:

  1. Open your project's Maven pom.xml file.
  2. Locate the <dependency> section for WebDriverManager.
  3. Update the version number to the latest available version. Here's an example:

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

Ensure that you replace 5.7.0 with the most recent version of WebDriverManager.

  1. Save the pom.xml file.
  2. Maven will automatically download the updated version of WebDriverManager the next time you build your project.

It's important to note that WebDriverManager is often used with Selenium WebDriver. Ensure you also have Selenium WebDriver included as a dependency in your pom.xml file. Here's an example:

<dependency>
  < groupId>org.seleniumhq.selenium</groupId>
   <artifactId>selenium-java</artifactId>
   <version>4.18.1</version>
</dependency>

Note: Selenium 4 provides built-in browser driver management similar to WebDriverManager. Therefore, if you use Selenium 4, you may not need to use WebDriverManager separately. You can directly instantiate the browser driver without additional configuration, as shown in your provided code snippet:

class SeleniumManagerTest {
   void managerTest()
{WebDriver driver = new ChromeDriver();}}

This code demonstrates a simple test method named managerTest(), which instantiates a ChromeDriver without explicit browser driver configuration. The absence of an additional setup highlights the convenience that WebDriverManager or Selenium 4's built-in driver management offers. This approach streamlines the process of creating browser driver instances, making the code cleaner and more concise.