6

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

8
  • Can you please specify chrome browser version? Commented Aug 16, 2018 at 11:41
  • Yes of course, my chrome is up to date as of the time i'm writing this. Version 68.0.3440.106 (64-bit). Commented Aug 17, 2018 at 12:42
  • I have the same problem!! Commented Aug 20, 2018 at 1:35
  • stackoverflow.com/questions/38846079/… Commented Aug 23, 2018 at 9:21
  • Thank you for the link but it seems that thread addresses a different issue. My problem is that my WebDriver can't create a Chrome process. I've looked at any logs left behind but i can't seem to make any sense of them. I don't think the problem is in the server. Commented Aug 29, 2018 at 12:55

2 Answers 2

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

This absolutely fixed my issue on win10
5

(for Mac) Change binary path from

/Applications/Google\ Chrome.app

..to:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.