selenium 2 chrome driver

后端 未结 10 569
情书的邮戳
情书的邮戳 2020-12-05 03:23

So I have read all the docs on adding chromedriver to my path and followed all of them. I am on a Mac with selenium2, maven, eclipse, and all the latest drivers:

<         


        
相关标签:
10条回答
  • 2020-12-05 03:48

    Try this:

    System.setProperty("webdriver.chrome.driver","/location to/chromedriver folder");
    WebDriver driver = new ChromeDriver();
    driver.get("your.app");
    
    0 讨论(0)
  • 2020-12-05 03:49

    It works for me without setting webdriver.chrome.driver property. Just by adding chromedriver to PATH

    > echo $PATH
    /usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin
    >    
    > which chromedriver
    /usr/local/bin/chromedriver
    

    If you use Homebrew, installing chromedriver along with adding to PATH can be done as simple as this:

    brew install chromedriver
    

    Useful links:

    https://sites.google.com/a/chromium.org/chromedriver/

    http://brewformulas.org/Chromedriver

    0 讨论(0)
  • 2020-12-05 03:50

    Just add WebDriverManager in your maven pom and it works without manual setup if you have your browser setup in default config.

    0 讨论(0)
  • 2020-12-05 03:54

    Add this dependency to your project:

    <dependency>
       <groupId>io.github.bonigarcia</groupId>
       <artifactId>webdrivermanager</artifactId>
        <version>4.2.2</version>
    </dependency>
    

    This library downloads the latest version of the WebDriver binary you need and export the proper Java system variable (webdriver.chrome.driver, webdriver.gecko.driver, webdriver.opera.driver, phantomjs.binary.path, webdriver.edge.driver, webdriver.ie.driver), simply using one of the following sentences respectively:

    WebDriverManager.chromedriver().setup();
    WebDriverManager.firefoxdriver().setup();
    WebDriverManager.operadriver().setup();
    WebDriverManager.phantomjs().setup();
    WebDriverManager.edgedriver().setup();
    WebDriverManager.iedriver().setup();
    

    More info on https://github.com/bonigarcia/webdrivermanager

    0 讨论(0)
提交回复
热议问题