Getting “The path to the driver executable must be set by the webdriver.chrome.driver system property”though set correct path

前端 未结 10 1636
攒了一身酷
攒了一身酷 2020-12-10 11:30

My code is very simple code:

WebDriver wd =new ChromeDriver();
  System.setProperty("webdriver.chrome.driver",
                     "D:\\\\List         


        
10条回答
  •  旧时难觅i
    2020-12-10 12:13

    I totally agree with Murthi, but better is to set relative path to the driver, NOT the absolute.

    Relative path looks like:

    System.setProperty("webdriver.chrome.driver", "src/test/resources/drivers/chromedriver.exe");
    

    Abosulte: is the path to the driver in your PC.

    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    

    Why? It is a good practice to have driver inside your project, not just in your computer. Just find or create folder f.e. resources, inside resources create folder called f.e. drivers and import your driver/drivers exe files there.

提交回复
热议问题