Monday

WebDriverManager - Solution to the selenium binaries


What is WebDriverManager ?

Problem: 

In order to use some browsers (for example Chrome,Internet ExplorerOperaMicrosoft EdgePhantomJS, or Marionette) you need to download a binary which allows WebDriver to handle the browser. In addition, the absolute path to this binary must be set as Java variables, as follows:
System.setProperty("webdriver.chrome.driver", "/absolute/path/to/binary/chromedriver");
System.setProperty("webdriver.opera.driver", "/absolute/path/to/binary/operadriver");
System.setProperty("webdriver.ie.driver", "C:/absolute/path/to/binary/IEDriverServer.exe");
System.setProperty("webdriver.edge.driver", "C:/absolute/path/to/binary/MicrosoftWebDriver.exe");
System.setProperty("phantomjs.binary.path", "/absolute/path/to/binary/phantomjs");
System.setProperty("webdriver.gecko.driver", "/absolute/path/to/binary/geckodriver");
Solution
This piece of software is a small library aimed to automate the Selenium Webdriver binaries management within a Java project in runtime.

What it does?

  1. It checks the latest version of the WebDriver binary file
  2. It downloads the binary WebDriver if it is not present in your system
  3. It exports the required Java variable by Selenium WebDriver

Usage
In order to use WebDriverManager in a Maven project, first add the following dependency to your pom.xml:
<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>1.4.6</version>
</dependency>
So far, WebDriverManager supports ChromeOperaInternet ExplorerMicrosoft EdgePhantomJS, or Marionette as follows:
ChromeDriverManager.getInstance().setup();
InternetExplorerDriverManager.getInstance().setup();
OperaDriverManager.getInstance().setup();
EdgeDriverManager.getInstance().setup();
PhantomJsDriverManager.getInstance().setup();
MarionetteDriverManager.getInstance().setup();


WebDriverManager (Copyright © 2015-2016) is a personal project of Boni Garcia licensed under LGPL License. Comments, questions and suggestions are always very welcome!
Source: https://github.com/bonigarcia/webdrivermanager

9 comments:

  1. Anonymous27/7/16

    #1.What are the advantages of this over traditional approach?

    #2. Will this works smoothly on grid?

    ReplyDelete
    Replies
    1. #1. The advantages, you don't have to worry what system you are working on , it downloads the appropriate jars. You also just have a single dependency and dont have to worry about the latest versions.
      #2 Yes it does , there is also a similar nuget version.

      Delete
  2. Thank you Ady..Your blog looks cool

    ReplyDelete
    Replies
    1. Thanks Vinod, Its a random testing blog like you would see :)

      Delete
  3. Your content is awesome . You have done a great job and its very useful for me . I appreciate your effort and I hope that you will get more positive comments from the web users.
    ROI Services in Chennai

    ReplyDelete
  4. where is the grid setup?

    ReplyDelete
    Replies
    1. @Nikol - Docker with Grid should do the trick even if the code seems to work on the local JVM from where the getInstance().setup() is being called.

      Delete
  5. Anonymous19/8/16

    Why do you have to copy your content from the original website exactly as it is?

    https://github.com/bonigarcia/webdrivermanager

    ReplyDelete
  6. How to use this in eclipse?

    ReplyDelete