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 ?
-
1gecko driver or chrome driver are executable binary files, Maven is the repository for Java .jar files and resources. However, if you still need non java binary to be uploaded and used through Maven Repo, you can follow this post: https://rolfje.wordpress.com/2013/07/18/non-java-binary-dependencies-in-maven/ – nandal May 28 '18 at 12:20
-
there are some maven plugins which download the binaries automatically. eg. https://github.com/webdriverextensions/webdriverextensions-maven-plugin and https://github.com/webdriverextensions/webdriverextensions-maven-plugin – Murthi May 28 '18 at 13:07
-
You can use cURL to download drivers by version – Nael Marwan May 28 '18 at 14:10
2 Answers
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

- 300
- 2
- 15

- 884
- 7
- 14
Check out this link for more clarification//use below the line it'll solve for chrome
WebDriverManager.chromedriver().browserVersion("77.0.3865.40").setup();
WebDriver driver = new ChromeDriver();
driver.get("URL");
//also you need to add below dependency into POM file`
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.2.1</version>
</dependency>`

- 1
- 1