WebdriverManager Implementation in Selenium

 Implement WebdriverManager in Selenium

In this post we will see how to implement the WebdriverManager with our selenium script

Selenium WebDriver is an automation tool widely popular and is useful to run tests against multiple browsers like Google Chrome browser, Firefox Browser, Internet Explorer, etc. This type of testing done on different browsers is usually known as Cross-Browser Testing.

 So if we want to launch any of these browsers' drivers for testing, First we have to download the webdriver executable file for the respective desktop browser then we have to set the corresponding executable path explicitly. After that, we instantiate the appropriate driver instance and go ahead with the code we want to execute. These steps become very hectic and old tradition as we need to carry them out every time the browser versions change. Hence we use the "WebDriverManager" class in Selenium.


 

Advantages of WebdriverManager :

  1. No need to download the chrome.exe, geckodriver.exe files etc..
  2. No need to set driver exe file path in selenium program
  3. No need to bother about the latest version of browser and exe files
  4. So, no issues with browser updates and exe files

To start with it, add below maven dependency into pom.xml or download jar files from here:

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

How we can do the initiation in our script to setup the webdriver manager for respective browser 

Syntax:
WebDriverManager.chromedriver().setup();

Above syntax will download chromedriver exe file in run time during your program. For first time it takes a while to launch your browser.

Sample Program:

public class WebDriverManagerDemo
 {
    public static void main(String[] args)
    {
        WebDriverManager.chromedriver().setup();
        WebDriver driver = new ChromeDriver();
        driver.get("https://automationeducator.blogspot.com");
    }
}

Similarly, we can implement it for another browser also using the other browser setup

  1. WebDriverManager.chromedriver().setup();
  2. WebDriverManager.firefoxdriver().setup();
  3. WebDriverManager.iedriver().setup();
  4. WebDriverManager.edgedriver().setup();
  5. WebDriverManager.operadriver().setup();
  6. WebDriverManager.phantomjs().setup();
Is it possible to Download a Particular version of the Browser using WebDriverManager?
Yes, it’s possible to download a particular version using Webdrivermanager.

Syntax:
  1. chromedriver().version(“2.26”).setup()
               Above syntax will download 2.26 version of chrome driver.
  2. firefoxdriver().arch32().setup()
              Using the Above syntax you will be able to download the 32-bit Firefox driver.
Hope this blog will help to solve your requirement......

Post a Comment

Previous Post Next Post