No More Driver EXE files for Selenium Execution – Instead Use WebDriverManager
Why do we use executable files for Launching browser using selenium?
After selenium 3, We got habituated to download exe files like chrome.exe, geckodriver.exe etc. to launch browsers. All these executable files are standalone server executable files that implements JSON-wire protocol and works as a glue between the test script and Browsers.
Most often, when we have updates of our browser, we have to update exe files as well to implement JSON-wire Protocol. So, All the time We need download updated EXE files and we need to update our repository.
We have an alternate to escape from those hurdles with Webdriver Manager Library.
Web Driver Manager Reference Link:
https://github.com/bonigarcia/webdrivermanager
Advantages of WebdriverManager :
- No need to download the chrome.exe,geckodriver.exe files etc..
- No need to set driver exe file path in selenium program
- No need to bother about the latest version of browser and exe files
- So, no issues with browser updates and exe files
To start with it, add below maven dependency or download jar files from here:
<dependency> <groupId>io.github.bonigarcia</groupId> <artifactId>webdrivermanager</artifactId> <version>3.0.0</version> <scope>test</scope> </dependency>
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("http://automationtesting.in"); } }
Is it possible to Download Particular version of Browser using WebDriverManager?
Yes, it’s possible to download particular version using Webdrivermanager.
Syntax:
- chromedriver().version(“2.26”).setup()
- Above syntax will download 2.26 version of chrome driver.
- firefoxdriver().arch32().setup()
- Using Above syntax you will be able to download 32 bit Firefox driver.
Sample Program with ChromeDriver Version 2.26:
public class WebDriverManagerDemo { public static void main(String[] args) { WebDriverManager.chromedriver().version("2.26").setup(); WebDriver driver = new ChromeDriver(); driver.get("http://automationtesting.in"); } }
Above program will download the 2.26 version of chromedriver exe file and used the same to launch the browser.
Please watch YouTube video for better understanding.
– This blog written by SUBBARAYUDU DARISIPUDI.