Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromedriver in Java not executable

So i'm trying to to learn Selenium and encountered a problem. Can't run chromedriver.

Error:

Exception in thread "main" java.lang.IllegalStateException: The driver is not executable: /Users/Roberto/Documents/EclipseProjects/MansPirmaisSelenium/lib/chromedriver

Code:

System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//lib//chromedriver");
WebDriver chromeDriver = new ChromeDriver();
chromeDriver.get("http://www.google.lv");

I have my chromedriver in the right path i guess, here is the image. enter image description here

like image 286
Roberts Šensters Avatar asked Feb 19 '16 15:02

Roberts Šensters


People also ask

How do I fix Chromedriver executable in path?

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.

How do I fix driver executable does not exist?

There might be two possibilities for this error. First, the path of the exe file may not be correct or secondly chrome driver may not be compatible with your chrome browser[incompatibility related issue]. 1. Copy chrome drive into your local file directory say test folder in D drive.

Why do people get IllegalStateException?

The IllegalStateException is thrown when the Java environment or application is not in an appropriate state for the requested operation. This can occur when dealing with threads or the Collections framework of the java. util package under specific conditions.


1 Answers

I assume you just downloaded the chromedriver application, in which case you simply have to mark it as executable in Unix:

chmod +x chromedriver 

If you can run the application yourself from the terminal, then WebDriver should be able to as well.

By the way, I wouldn't include chromedriver inside your project:

  • You'll want to reuse it on other projects
  • According to the documentation:

include the ChromeDriver location in your PATH environment variable

like image 154
Andrew Regan Avatar answered Sep 22 '22 08:09

Andrew Regan