0

I got this error message when I try to launch Chrome with Selenium WebDriver in Java Eclipse. (Java Eclipse is in USB stick) Java code - package SeleniumSessions;

import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class WebDriverBasics { public static void main(String[] args) { // TODO Auto-generated method stub // chrome browser System.setProperty("webdriver.gecko.driver", "C:\\Users\\waychal\\Downloads\\geckodriver.exe"); WebDriver driver = new ChromeDriver(); // launch Chrome browser driver.get("https://www.google.com/"); } } 

Error messages-

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html at com.google.common.base.Preconditions.checkState(Preconditions.java:847) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134) at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35) at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159) at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123) at SeleniumSessions.WebDriverBasics.main(WebDriverBasics.java:15) 
3
  • Please verify that your geckoDriver.exe is located in correct folder or not.CommentedMar 13, 2019 at 11:07
  • The problem is that, you are using webdriver.gecko.driver, which is used to access firefox. To set the path of the chromedriver you need to replace webdriver.gecko.driver with webdriver.chrome.driverCommentedMar 14, 2019 at 11:05
  • 1
    you can also try putting a try-catch for 3s inside the main method. try { Thread.sleep(3000); } catch (InterruptedException e) { e.printStackTrace(); }
    – TinTin
    CommentedMar 3, 2020 at 9:00

1 Answer 1

3

The exception asks for a path to the chrome driver

The path to the driver executable must be set by the webdriver.chrome.driver system property 

You are setting it for the gecko driver

 System.setProperty("webdriver.gecko.driver", "C:\\Users\\Downloads\\geckodriver.exe"); 

I don't exactly know but I would recommend you to use the Chromedriver and also set the correct property.

1
  • Thanks for your quick answer. I had already resolved this Problem after posting this question :D. I had tried the sample program from youtube which was for Mac user and hence gecodriver.
    – raw
    CommentedMar 15, 2019 at 10:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.