java - Selenium WebDriver failed to create chrome process

Declan picture Declan · Aug 15, 2018 · Viewed 8.8k times · Source

So I have been trying to make a program that can interact with a webpage to input data. I ideally wanted to use Chrome so I tried to set up Selenium WebDriver and ChromeDriver.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class Chrome {

public static void main(String[] args) {

    //Set chromedriver path
    System.setProperty("webdriver.chrome.driver","C:/Users/Username/Desktop/Comp Sci work/chromedriver.exe");

    WebDriver driver = new ChromeDriver();

     // Open Google
    driver.get("http://www.google.com");

    // Maximize browser
    driver.manage().window().maximize();

}
}

I seem to have set up the external JARs correctly as I can import them with no problem. The problem is for some reason the Chrome process cannot be created. I thought this might've been because there was already a Chrome process open but no. I still got the same error when I killed the process.

I then tried to set reset the path to Chrome, as the default one might've been different to mine, but still no luck.

public class Chrome {

public static void main(String[] args) {

    //Set chromedriver path
    System.setProperty("webdriver.chrome.driver","C:/Users/Username/Desktop/Comp Sci work/chromedriver.exe");

    ChromeOptions options = new ChromeOptions();
    options.setBinary("C:\\Users\\Username\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe");

    WebDriver driver = new ChromeDriver();

     // Open Google
    driver.get("http://www.google.com");

    // Maximize browser
    driver.manage().window().maximize();

}
}

The error message is:

Starting ChromeDriver 2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e) 
on port 43997
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown 
error: Failed to create a Chrome process.
(Driver info: chromedriver=2.41.578737 
(49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.17134 
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 199 milliseconds
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08- 
02T20:05:20.749Z'

As the chromedriver seems to start fine the problem is simply in creating the chrome process but I can't seem to find out why. Any help would be appreciated(Also tips about my post formatting, as this is my first post). Thanks

Answer

fly Lee picture fly Lee · Feb 13, 2019

I meet this problem today,and solved it finally.it's because the chrome run as Administrator.so java can't start it.

Google Chrome Properties->Compatibility->not run as administrator