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
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>`
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