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?
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.
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.
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.
System.setProperty("webdriver.chrome.driver",
"/home/vin/Downloads/chromedriver");
Note- write the chromedriver without mentioning .exe (In Ubuntu and Mac)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With