在 selenium 中使用 chromedriver 时出现 IllegalAccessError。我已将 chromedriver.exe 添加到我的路径中,并将其设置为 java 代码。这是我的代码
System.setProperty("webdriver.chrome.driver","C:/Users/me/Documents/chromedriver/chromedriver.exe");
WebDriver driver = new ChromeDriver();
这是控制台输出:
Exception in thread "main" java.lang.IllegalAccessError: tried to access method org.openqa.selenium.remote.service.DriverService.checkExecutable(Ljava/io/File;)V from class org.openqa.selenium.chrome.ChromeDriverService
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:39)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.usingDriverExecutable(ChromeDriverService.java:104)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:72)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107)
我也尝试运行 chromedriver.exe 然后执行代码,仍然出现错误。