Can we add gecko driver , ie driver or chrome driver as depandancy in POM? I tried to search but was not able to fine them on https://mvnrepository.com/artifact. Any reason why they are not placed on the maven repository ?
As few comments mentioned, that driver are executable binary files. Maven cannot help you with that as it's just a dependency repository. Currently to run selenium for example on firefox we need to write :
System.setProperty("webdriver.gecko.driver", "driverpath/.exe");
WebDriver driver = new FirefoxDriver();
However we have new solution that will make us get rid if the first line of code and you won't need to download the dirver binary files anymore. Its called WebDriverManager and it's a dependency that can be added using Maven pom file. This will call the driver during run time with the latest version number. All you need to write now is :
WebDriverManager.firefoxdriver().setup();
WebDriver driver = new FirefoxDriver();
and you need to add this dependency in the pom file
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.2.1</version>
</dependency>
For more information about this please go to Github link to check all the rest of the driver like chrome , ie , etc.. WebDriverManagerLink
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With