Can we add drivers in selenium as maven depandancies

后端 未结 2 647
既然无缘
既然无缘 2020-12-19 14:55

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

2条回答
  •  半阙折子戏
    2020-12-19 15:25

    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

    
        io.github.bonigarcia
        webdrivermanager
        2.2.1
    
    

    For more information about this please go to Github link to check all the rest of the driver like chrome , ie , etc.. WebDriverManagerLink

提交回复
热议问题