0

I am trying to create Selenium Chrome driver object but its failing on creation.

It seems the code doesn't recognize the path of the driver, although it was copied manually to /home/build/drivers/chromedriver in the target machine...

The code is running on Jenkins slave, which is the target machine I want to create the driver.

Here are some technical details :

Java version : 1.8 Selenium Java version : 3.14.0

Chrome browser : 76.0.3809.68

Chrome driver (Linux 64 BIT) : 76.0.3809.68

The source code attached :

public <T extends WebDriver> T createChromeDriver()  {
        String driverPath = new File("/home/build/drivers/chromedriver");
        ChromeOptions options = new ChromeOptions();
        System.setProperty(CHROME_DRIVER, driverPath);
//            options.addArguments("--disable-extensions");
            options.addArguments("headless");
            options.addArguments("--disable-gpu");
            options.addArguments("disable-infobars");
            options.addArguments("--disable-extensions");
            options.addArguments("window-size=1200x600");
            options.addArguments("--no-sandbox");
            options.addArguments("start-maximized");
            options.addArguments("disable-notifications");
            options.addArguments("allow-running-insecure-content");
            return new ChromeDriver(options);
}

Here is the full stack trace :

java.lang.IllegalStateException: The driver executable does not exist: /home/build/drivers/chromedriver
    at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:137)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:132)
    at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:156)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:346)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:91)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at com.intigua.automation.jet_patch.selenium_services.driver.SeleniumDriver.createChromeDriver(SeleniumDriver.java:130)
    at com.intigua.automation.jet_patch.selenium_services.driver.SeleniumDriver.createDriver(SeleniumDriver.java:55)
    at com.intigua.jet_patch.RailRunnerTest.setUp(RailRunnerTest.java:62)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
  • Is it running fine on your machine? Also do you have sufficient privilege on the folder where your ChromeDriver is kept/ – demouser123 Aug 17 '19 at 15:58
  • My machine is Windows 10, there the driver fails on something else (some devTool exception)...... Regarding the privilege, I didn't attach this piece of code before, but I ran runCommand("chmod 777 " + driverPath); and it didn't failed. – user6441133 Aug 17 '19 at 16:08
  • 1
    `/home/build` looks strange, the user is `build` ? Can you show us the output of `ls` on the file ? to be sure that it exists – Arnaud Claudel Aug 17 '19 at 16:18
  • I would suggest to use the WebDriverManager: https://github.com/bonigarcia/webdrivermanager – AndiCover Aug 17 '19 at 16:31
  • I succeeded to only upload FireFox driver locally... – user6441133 Aug 18 '19 at 12:50
  • I used WebDriverManager, and I succeeded to only create Fire Fox driver locally...When I try to ccrete FireFox driver on slave I get : org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities – user6441133 Aug 18 '19 at 12:55
  • In Chrome Driver I get the same exception...org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities Can anyone assist????? – user6441133 Aug 18 '19 at 13:40

0 Answers0