Java Selenium Chromedriver.exe不存在IllegalStateException [英] Java Selenium Chromedriver.exe Does not Exist IllegalStateException

查看:72
本文介绍了Java Selenium Chromedriver.exe不存在IllegalStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我收到的错误消息:

Here is the error message I'm getting:

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Users\Scott\workspace\Twitch%20Bot%20v2\bin\chromedriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:197)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:122)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:117)
    at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:118)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:291)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:82)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:117)
    at com.fatalcubez.main.Bot.setup(Bot.java:41)
    at com.fatalcubez.main.Bot.<init>(Bot.java:29)
    at com.fatalcubez.main.BotGUI.<init>(BotGUI.java:17)
    at com.fatalcubez.main.Main.main(Main.java:14)

这是我正在使用的代码:

And here is the code that I'm using:

ClassLoader loader = ClassLoader.getSystemClassLoader();
        URL path = loader.getResource("chromedriver.exe");
        System.setProperty("webdriver.chrome.driver", path.getPath());

我已经检查了目录中搜索chromedriver的位置,它就在那里。我不确定此时的问题是什么。任何帮助都会很棒!

I've already check the directory for where it is searching for the chromedriver and it's there. I'm not sure what the problem is at this point. Any help would be great!

编辑:这只是文件夹名称中间距的问题,但现在我有另一个问题。当我尝试启动chrome时,它说管理员已在此计算机上安装了chrome ....我该怎么办?

It was simply a problem with spacing in the folder name, but now I have another problem. When I try to launch chrome it says "An administrator has installed chrome on this computer...." What can I do?

推荐答案

您必须提供chromeDriver.exe文件路径,而不是从URL中获取路径。

You have to give your chromeDriver.exe file path instead of taking the path from the URL.

示例:

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

这篇关于Java Selenium Chromedriver.exe不存在IllegalStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆