gpt4 book ai didi

java - 线程 “main”中的异常java.lang.IllegalStateException : The driver executable is a directory

转载 作者:行者123 更新时间:2023-12-03 09:12:41 26 4
gpt4 key购买 nike

获取以下异常:

Exception in thread "main" java.lang.IllegalStateException: The driver executable is a directory: C:\Users\OpExWorks\Desktop\Google Chrome at com.google.common.base.Preconditions.checkState(Preconditions.java:585) at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:148) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123) at test001.test002.main(test002.java:12)


代码:
package test001;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public abstract class test002 {

public static void main(String[] args)
{

System.setProperty("webdriver.chrome.driver","C:\\Users\\OpExWorks\\Desktop\\Google Chrome");
WebDriver w=new ChromeDriver();
w.get("https://www.opexworks.in/Sathi/Default.aspx");
}
}

最佳答案

webdriver.chrome.driver必须指向可执行文件,并且从代码中看起来像您在Windows上。因此,它应该是.exe文件的路径。如果文件名为“chromedriver.exe”,则应使用:

System.setProperty("webdriver.chrome.driver","C:\\Users\\OpExWorks\\Desktop\\Google Chrome\\chromedriver.exe");

关于java - 线程 “main”中的异常java.lang.IllegalStateException : The driver executable is a directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62662199/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com