我收到错误驱动程序可执行文件不存在:在system.getproperty上



我在下面写了代码,每次运行代码时都会收到错误:

线程"main"中的异常 java.lang.IllegalStateException: 驱动程序可执行文件不存在: C:\Users\chromedriver.chromedriver.exe

请帮我弄清楚这是什么原因

package seleniumsession;
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.chrome.ChromeDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
public class launchdriver
{
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "C:\Users\chromedriver.chromedriver.exe");
        WebDriver driver = new ChromeDriver();
    }
}

而不是使用文件名作为"chromedriver.chromedriver.exe",您应该在文件夹"chromedriver"下使用文件名作为"chromedriver.exe",并创建目录层次结构,如下面的代码片段中所述。

System.setProperty("webdriver.chrome.driver", 
"C:\Users\chromedriver\chromedriver.exe");
WebDriver driver = new ChromeDriver();

系统正在做什么,它正在考虑"chromedriver.chromedriver.exe"作为模棱两可的chrome驱动程序,因为Selenium无法在提供的目录上找到chrome驱动程序。

最新更新