WebDriverManager Class in Selenium

WebDriverManager Class in Selenium

Browser drivers, such as chromedriver.exe for Chrome or geckodriver.exe for Mozilla, are required to run Java-Selenium scripts.

We need to download those drivers and set the path in the script manually. Sometimes, when the browser version doesn’t match with the downloaded drivers, automation scripts can not be run. It is quite cumbersome to download manually and manage these browser drivers by checking current browsers.

WebDriverManager class in Selenium allows to automatically download driver binaries without having to set up path in scripts.

Hence, It should be downloaded in any directory, and WebDriverManager downloads the driver to a local cache.

However, we can set the path in scripts where the driver will be downloaded. This task can be accomplished using the following lines of codes.

Maven Dependency for WebDriverManager:

<dependencies>
  <dependency>
  ? ? <groupId>io.github.bonigarcia</groupId>
  ? ? <artifactId>webdrivermanager</artifactId>
  ? ? <version>5.1.1</version>
  </dependency>
</dependencies>        

Chrome Code Snippet for WebDriverManager:

import io.github.bonigarcia.wdm.WebDriverManager; 

WebDriverManager webDriverManager;

webDriverManager = WebDriverManager.chromedriver();

webDriverManager.config().setCachePath("Path Location"); //Provide the path where you want to download the driver

webDriverManager.setup();        

I hope you found this post to be beneficial. Thanks!

Manjurul Hoque Rumi

Software Engineer | Django, FastAPI | Go | AWS | Docker, Kubernetes | 5+ years experience

2 年

Good work brother!

Md Sharif Khan

Senior Software Developer in Test | Selenium | API | Backend Automation | Jenkins | AWS SAA-CO2 | DevOps

2 年

Well done Shuvo.

Md. Hasnat Shoheb

Sr. Software Quality Assurance Engineer at SELISE Digital Platforms | QA Automation Engineer

2 年

Great Work bhai

要查看或添加评论,请登录

Anwar Hasan Shuvo的更多文章

  • How to use fake GPS on iOS devices

    How to use fake GPS on iOS devices

    Here's a simple guide to use fake GPS on iOS devices using Xcode: Launch Xcode and click on the Create a new Xcode…

社区洞察

其他会员也浏览了