October 2, 2018

Automatic download and management of Selenium WebDriver binaries (Driver.exe files)

In this post we will see how to avoid downloading driver.exe file and setpath for browser binary.

As you guys already know in order to use chrome, firefox or edge browsers, first we need to download a binary file (driver.exe) and need to set path which allows Webdriver to handle browsers.



Below is example how to set path:


By adding a small dependency in your POM.xml (Assuming you are using maven project) we can avoid downloading binary files and set path. In addition, we have to check manually when new versions of the binaries are released. WebDriverManager will do this job for us automatically


How it works:

WebDriver Manager actually gets your browser version and download the compatible browser binary by itself to make you run your code without interruption.

So now, rather than setting the browser binaries, you just need to add below line of code and you’re done


The line WebDriverManager.chromedriver().setup(); WebDriverManager does magic for you:

  1. It checks for the latest version of the WebDriver binary.
  2. It downloads the WebDriver binary if it’s not present on your system.
  3. It exports the required WebDriver Java environment variables needed by Selenium
By default downloaded binary files (driver.exe) files will be stored in .m2 folder. By using below commands you can get the downloaded version and path of binary file.


Below is sample code:



Video is available here:


9 comments:

  1. Very informative blog sir. Thank you for the sharing.

    ReplyDelete
  2. Nice blog..! I really loved reading through this article. Thanks for sharing such an amazing post with us and keep blogging...Well written article Thank You for Sharing with Us | project management training in chennai | project management certification online | project management course online |

    ReplyDelete


  3. افضل شركة نقل عفش من الرياض الى مصر شركة شحن عفش من الرياض لمصر
    افضل شركة نقل عفش بالدمام افضل شركة نقل عفش بالدمام
    افضل شركة نقل عفش بالاحساء افضل شركة نقل عفش بالاحساء
    نقل عفش داخل مكة نقل عفش في مكة

    ReplyDelete
  4. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing.
    Selenium Testing Course Online
    Best Selenium Course Online

    ReplyDelete