Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Selenium Chromedriver.exe Does not Exist IllegalStateException

Tags:

java

selenium

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());

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!

EDIT: 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?

like image 674
Scooter Avatar asked Jun 06 '15 22:06

Scooter


People also ask

Why do we get IllegalStateException in selenium?

An IllegalStateException is thrown while working with Chrome browser if the chromedriver.exe file path is set incorrectly in the method System. setProperty. Once this executable file is downloaded, it has to be extracted. Then its path should be copied and added as a parameter to the System.

How do I add Chromedriver EXE to path?

Go to the terminal and type the command: sudo nano /etc/paths. Enter the password. At the bottom of the file, add the path of your ChromeDriver. Type Y to save.

How do I fix Chromedriver executable in path?

Conclusion # To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.


1 Answers

System.setProperty("webdriver.chrome.driver",
            "/home/vin/Downloads/chromedriver");

Note- write the chromedriver without mentioning .exe (In Ubuntu and Mac)

like image 145
vinee Avatar answered Sep 21 '22 11:09

vinee