Maven + Chrome Driver + "The driver is not executable" error

17,825 views
Skip to first unread message

Tarun Kumar

unread,
Jun 18, 2012, 1:16:45 AM6/18/12
to seleniu...@googlegroups.com
I have been using chrome driver in past as - 

     System.setProperty("webdriver.chrome.driver", "path to chrome driver");

I thought I could utilize the resource feature of maven and kept it in src/main/resources folder. Following this I invoke it from base class as -

System.setProperty("webdriver.chrome.driver", BaseClass.class.getResource("/chromedriver").getPath());
driver = new ChromeDriver(); 

But while executing Junit test I encounter error -

java.lang.IllegalStateException: The driver is not executable: /home/<path to project>/Commons/target/classes/chromedriver
Has any one tried to use resource folder or any other approach with maven and chrome driver?

Thanks
Tarun K

Pradeep Siluveru

unread,
Jun 18, 2012, 1:30:46 AM6/18/12
to seleniu...@googlegroups.com
I have done like using maven dependency plugin copied into specific location like(public static String WINDOWS_DIRECTORY="/target"+"/test"+"/chromedriver"+"/windows") here the chrome driver will get added then from code i pointed to this location using System.getProperty("user.dir");+target directory.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/NSCBa3hv4pYJ.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.



--
Thanks&Regards,
S.PradeepKumar

Tarun Kumar

unread,
Jun 18, 2012, 1:57:42 AM6/18/12
to seleniu...@googlegroups.com
Thanks Pradeep, I guess your configuration is almost similar to what I have.
I was wondering when I indeed have chrome driver in location - /home/<path to project>/Commons/target/classes/ why I encounter the error "The driver is not executable"- 


On Monday, June 18, 2012 11:00:46 AM UTC+5:30, Pradeep Siluveru wrote:
I have done like using maven dependency plugin copied into specific location like(public static String WINDOWS_DIRECTORY="/target"+"/test"+"/chromedriver"+"/windows") here the chrome driver will get added then from code i pointed to this location using System.getProperty("user.dir");+target directory.

On Mon, Jun 18, 2012 at 10:46 AM, Tarun Kumar <tku...@gmail.com> wrote:
I have been using chrome driver in past as - 

     System.setProperty("webdriver.chrome.driver", "path to chrome driver");

I thought I could utilize the resource feature of maven and kept it in src/main/resources folder. Following this I invoke it from base class as -

System.setProperty("webdriver.chrome.driver", BaseClass.class.getResource("/chromedriver").getPath());
driver = new ChromeDriver(); 

But while executing Junit test I encounter error -

java.lang.IllegalStateException: The driver is not executable: /home/<path to project>/Commons/target/classes/chromedriver
Has any one tried to use resource folder or any other approach with maven and chrome driver?

Thanks
Tarun K

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/NSCBa3hv4pYJ.
To post to this group, send email to selenium-users@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.



--
Thanks&Regards,
S.PradeepKumar

Pradeep Siluveru

unread,
Jun 18, 2012, 2:00:14 AM6/18/12
to seleniu...@googlegroups.com
may i know your OS?

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/WpY2k6wfeGcJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.



--
Thanks&Regards,
S.PradeepKumar

Tarun Kumar

unread,
Jun 18, 2012, 2:10:02 AM6/18/12
to seleniu...@googlegroups.com
Ubuntu

Krishnan Mahadevan

unread,
Jun 18, 2012, 2:11:47 AM6/18/12
to seleniu...@googlegroups.com
Tarun,
That is because the path resolves to a directory and not the binary/executable of the ChromeDriver.
Please update your code to ensure that you are resolving to the binary/executable name and not to the directory in which your binary/executable resides in.

This is why you are seeing that error perhaps (Code from ChromeDriver class)

    checkState(exePath != null,
        "The path to the chromedriver executable must be set by the %s system property;"
            + " for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. "
            + "The latest version can be downloaded from "
            + "http://code.google.com/p/chromedriver/downloads/list", CHROME_DRIVER_EXE_PROPERTY);

    File exe = new File(exePath);
    checkState(exe.exists(),
        "The %s system property defined chromedriver executable does not exist: %s",
        CHROME_DRIVER_EXE_PROPERTY, exe.getAbsolutePath());
    checkState(!exe.isDirectory(),
        "The %s system property defined chromedriver executable is a directory: %s",
        CHROME_DRIVER_EXE_PROPERTY, exe.getAbsolutePath());


Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"



To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/i_XpAEuhiSsJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Tarun Kumar

unread,
Jun 18, 2012, 8:26:05 AM6/18/12
to seleniu...@googlegroups.com
Ended up in using -     System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"/chromedriver");
where I keep the chrome executable in parent maven module returned by - System.getProperty("user.dir").
Thanks all for your responses.

Homewrecker

unread,
Jul 13, 2012, 3:26:20 PM7/13/12
to seleniu...@googlegroups.com
We use a little utility to find the chromewebdriver.exe on the classpath itself using this method:

              URL url = FileUtils.class.getClassLoader().getResource(fileName);

Maybe this'll help you.

On Friday, July 13, 2012 6:05:48 PM UTC+2, Ziebold wrote:
I'm having a similar problem where I can't run chrome tests on a ubuntu box.  Below is my code that I'm trying to run...with the fix stated above I'm confused on how I'd fix my code to get it to work?  Any help would be appreciated.

public class Chrome {

  private static ChromeDriverService service;
  private WebDriver driver;

  @BeforeClass
  public static void createAndStartService() throws IOException {
    service = new ChromeDriverService.Builder()
        .usingChromeDriverExecutable(new File("src/test/resources/chromedriver"))
        .usingAnyFreePort()
        .build();
    service.start();
  }

  @AfterClass
  public static void createAndStopService() {
    service.stop();
  }

  @Before
  public void createDriver() {
    driver = new RemoteWebDriver(service.getUrl(),
        DesiredCapabilities.chrome());
  }

  @After
  public void quitDriver() {
    driver.quit();
  }

  @Test
  public void testGoogleSearch() {
    driver.get("http://www.google.com");
    WebElement searchBox = driver.findElement(By.name("q"));
    searchBox.sendKeys("webdriver");
  }
}

Pushpraj Singh

unread,
Sep 6, 2013, 7:45:44 AM9/6/13
to seleniu...@googlegroups.com
@Nagasagar : Did you try what you have suggested here to do?
Cause I tried and on running the tests I got this error :
unknown error: cannot find Chrome binary (Driver info: chromedriver=2.3,platform=Linux 3.5.0-21-generic x86_64) (WARNING: The server did not provide any stacktrace information)

@Tarun :
Could you please elaborate the fix...

On Friday, 14 September 2012 18:33:38 UTC+5:30, Nagasagar wrote:
Tarun,

I think the file you downloaded dont have execution permission. add execution permission to the file. From terminal   chmod +rwx chromedriver  . even though the post is old and you would have found this solution long  back . adding this reply for users who google with same issue :)
Ubuntu
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en-US.



--
Thanks&Regards,
S.PradeepKumar

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/i_XpAEuhiSsJ.

To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.

Pushpraj Singh

unread,
Sep 6, 2013, 1:08:08 PM9/6/13
to seleniu...@googlegroups.com
I tried :
String path = System.getProperty("/usr/share/maven/chromedriver");
System.setProperty("webdriver.chrome.driver", path);
        driver = new ChromeDriver();
but it didn't work...

Morgan Wren

unread,
Sep 6, 2013, 1:29:57 PM9/6/13
to seleniu...@googlegroups.com
Be sure to use /chromedriver.exe not just /chromedriver

Mark Collin

unread,
Sep 10, 2013, 7:11:18 AM9/10/13
to seleniu...@googlegroups.com
You could always try using my selenium-standalone-server-plugin (https://github.com/Ardesco/selenium-standalone-server-plugin)

Here's a link to a maven template that's using it https://github.com/Ardesco/Selenium-Maven-Template, the POM file is probably the most relevant part.
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

bsri

unread,
Sep 17, 2013, 4:47:39 PM9/17/13
to seleniu...@googlegroups.com
My requirement is to provide the junit code to execute from command line. So, I am trying to run mvn test -Dtest=<my main test class>. When I do this, I get an error in target\surefire-reports directory which says "java.lang.IllegalStateException: The driver executable does not exist: c:\eclipse\testautomationws\alltrack\file:\C:\Users\bsri\.m2\repository\testautomation\browser\0.0.1-SNAPSHOT\browser-0.0.1-SNAPSHOT-tests.jar!\chromedriver.exe".
 
I have a browser project and alltrack project. The alltrack project uses browser project - the job of the browser project is to encapsulate the webdriver.
 
The Chrome webdriver class in the browser project looks like this:
 

public

class ChromeWebDriver implements WebDriverInterface {

private WebDriver chromeWebDriverInstance;

 

private static org.slf4j.Logger testlogger = org.slf4j.LoggerFactory.getLogger(ChromeWebDriver.class);

public ChromeWebDriver() {

String path_to_chromedriver_executable=

this.getClass().getClassLoader().getResource("chromedriver.exe").getFile();

System.setProperty(

"webdriver.chrome.driver", path_to_chromedriver_executable);

DesiredCapabilities capabilities = DesiredCapabilities.chrome(); 

 

 

 

chromeWebDriverInstance = new ChromeDriver(capabilities);

}

public WebDriver startWebDriver() {

 

 

 

return chromeWebDriverInstance;

}

 
 
chromedriver.exe is under  test/resources in the browser project. Both projects follow Maven structure. Surefire copies all the .properties files into target\test-classes but not chromedriver.exe or IEDriverServer.exe.
 
What should I change in my pom.xml so this can happen? And, for which project? Should I change it in the alltrack project (which uses browser project that has chrome driver executable in its test/resources) or only browser or both?
 
 

Krishnan Mahadevan

unread,
Sep 17, 2013, 11:42:41 PM9/17/13
to seleniu...@googlegroups.com
There are a couple of problems here.
  1. You are fetching the path of the chromedriver incorrectly. Assuming that the binary resides under src/test/resources, you should ideally speaking be using this.getClass().getResource("/chromedriver.exe") [ you missed a slash in your test code ]
  2. Even if you did put your binary in your src/test/resources directory it would still give you the error [java.lang.IllegalStateException: The driver is not executable: /Users/krmahadevan/githome/PlayGround/testbed/target/test-classes/chromedriver] on a NON WINDOWS machine [ I run on a MAC]. The reason behind this seems to be more because of a bug in the test resource plugin. See here for more details and here for a possible alternative as well.
All that said and done, you might want to take a look at the selenium standalone server plugin that Mark Collins created . I checked the global repos and I see its there.  [ Latest version is 0.9.2 ]

Thanks Mark for having this published to the global maven repos.



Thanks and Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.

Hemant Ojha

unread,
Oct 20, 2015, 2:49:15 AM10/20/15
to Selenium Users
I use macOS.
For me it worked when I set its mode to executable.

Step1: go to the folder
Step2: "chmod +x chromedriver"

avi rao

unread,
Apr 2, 2018, 11:16:48 PM4/2/18
to Selenium Users
Thanks. That helped. 

Serguei Kouzmine

unread,
Apr 2, 2018, 11:55:40 PM4/2/18
to Selenium Users
On ubuntu if you put chromedriver under `~/Downloads` it will work (put a full path  like. `/home/joe/Downloads/chromedriver` to "webdriver.chrome.driver"
If you put it in e.g. `/var/run` - it won't,

Error will vary.
Serguei Kouzmine

Naresh Chaurasia

unread,
Apr 3, 2018, 4:36:18 AM4/3/18
to Selenium Users
I guess you are using Linux.

Go to the directory where you have the driver, and execute the following command.

chmod 777 <drivername>

In order to execute this command you required sudo permission.

~Naresh C

Serguei Kouzmine

unread,
Apr 3, 2018, 10:02:30 AM4/3/18
to Selenium Users
This issue is not solved by changing file mode, it is specific to /var/run and some other dirs

```
sudo cp ~/Downloads/chromedriver  /var/run
[sudo] password for sergueik: 
sergueik@sergueik19:~/src/SKDF/jprotractor$ sudo chmod +x /var/run/chromedriver 

mvn test
CREATE_BROWSER call method: openBrowser with 
Exception in openBrowser: java.lang.IllegalStateException: The driver is not executable: /var/run/chromedriver

```
run the whole test under root  ? does not change the behavior.
Placing into some directory in the user's home -  works

On Monday, June 18, 2012 at 1:16:45 AM UTC-4, Tarun Kumar wrote:

mahesh takkalwad

unread,
Jan 7, 2019, 9:33:45 AM1/7/19
to Selenium Users
it worked for also after changing the permisson
Reply all
Reply to author
Forward
0 new messages