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 :
- 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 into pom.xml or download jar files from here:
How we can do the initiation in our script to setup the webdriver manager for respective browser
Sample Program:
Similarly, we can implement it for another browser also using the other browser setup
- WebDriverManager.chromedriver().setup();
- WebDriverManager.firefoxdriver().setup();
- WebDriverManager.iedriver().setup();
- WebDriverManager.edgedriver().setup();
- WebDriverManager.operadriver().setup();
- WebDriverManager.phantomjs().setup();
- chromedriver().version(“2.26”).setup()
Above syntax will download 2.26 version of chrome driver. - firefoxdriver().arch32().setup()
Using the Above syntax you will be able to download the 32-bit Firefox driver.
Post a Comment