Roberts Šensters
Roberts Šensters

Reputation: 605

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

Upvotes: 6

Views: 18399

Answers (4)

santu roy
santu roy

Reputation: 11

I'm new to selenium-java and faced the same problem and solved by providing executable access as below in eclipse:

  1. Right click on chromedriver and click properties
  2. Under Resource Tab check owner > execute

Upvotes: 1

Vladyslav Borshch
Vladyslav Borshch

Reputation: 39

The problem is exactly in permissions to the chromedriver in the target directory. To solve the problem author mentioned above change your chromedrive initialization to the following:

System.setProperty(System.getProperty("user.dir") + "/src/test/resources/chromedriver");

of course use your own appropriate directory to the file.

Upvotes: -1

iltaf khalid
iltaf khalid

Reputation: 10308

File permissions for Unix based files can be checked and set via java like:

Check if the file permission allow :

file.canExecute(); – return true, file is executable; false is not.
file.canWrite(); – return true, file is writable; false is not.
file.canRead(); – return true, file is readable; false is not.

Set the file permission :

file.setExecutable(boolean); – true, allow execute operations; false to disallow it.
file.setReadable(boolean); – true, allow read operations; false to disallow it.
file.setWritable(boolean); – true, allow write operations; false to disallow it.

Upvotes: 3

Andrew Regan
Andrew Regan

Reputation: 5113

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

Upvotes: 18

Related Questions