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
Below are the steps to follow while configuring the chrome setup for Selenium. #1) Check the version of the chrome. #3) Download the chromedriver.exe file for the respective OS and copy that .exe file into your local. #4) The path of the chromedriver (C:\webdriver\chromedriver.exe) will be used in our program.
Through WebDriver, Selenium supports all major browsers on the market such as Chrome/Chromium, Firefox, Internet Explorer, Edge, and Safari.
WebDriver is an open source tool for automated testing of webapps across many browsers. It provides capabilities for navigating to web pages, user input, JavaScript execution, and more. ChromeDriver is a standalone server that implements the W3C WebDriver standard.
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
(for Mac) Change binary path from
/Applications/Google\ Chrome.app
..to:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With