
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 http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
The reason is probably that you have not told your system where to find your driver executable. Unlike when using the Firefox WebDriver you need to download a driver executable which is specifically for Chrome and builds the the conncection part between your Java Selenium program and the Chrome Webbrowser.
To fix this problem follow these steps:
- Download the latest ChromeDriver for your operating system here. If you work with windows choose “chromedriver_win32.zip”.
- Extract the content of the zip file (chromedriver.exe) to any place on your computer, that you will remember later.
- After replacing the location of the chromedriver.exe with the specific location on your computer, add the following code to your Selenium program before creating a new instance of ChromeDriver:
System.setProperty("webdriver.chrome.driver","C:/Your/Path/to/chromedriver.exe");
That’s it. Problem should be solved. A whole working code sample could then look like this (again, first you need to edit the location of the chromedriver.exe):
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; /** * @author Nils Schuette via frontendtest.org */ public class ChromeDriverTest { /** * @param args * @throws InterruptedException */ public static void main(String
[] args) throws InterruptedException {
// Telling the system where to find the chrome driver
System.setProperty(
"webdriver.chrome.driver",
"C:/Your/Path/to/chromedriver.exe");
WebDriver webDriver = new ChromeDriver();
// Maximize the browser window
webDriver.manage().window().maximize();
// Open google.com
webDriver.navigate().to("http://www.google.com");
// Waiting a little bit before closing
Thread.sleep(7000);
// Closing the browser and webdriver
webDriver.close();
webDriver.quit();
}
}
hi sir i’m trying but always error will coming above mention the error like that only
plz give me solution
Hey there, If you want, post a copy of your code an I will have a look at it.
Why do we use “//” while entering the path of the Chrome driver or any other driver in the System.setproperty command..???
Is there any specific reason for that..?
Hi Raymond, I am not totally sure what you mean. Im my example I am using “//” nowhere (but it would also work with //). Only if you use backslashes “\\” you actually must use them double because a single backslash tells java that the next character means “something special”. Two backslashes then are interpreted as a usual single one. Hope that helps.
Code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Sample_Selenium {
public static void main(String[] args) {
System.setProperty(“webdriver.chrome.driver”,”/Users/manmitshelar/Documents/Selenium/chromedriver.exe”);
WebDriver webDriver = new ChromeDriver();
Error:
Exception in thread “main” java.lang.IllegalStateException: The driver executable does not exist: /Users/Documents/Selenium/chromedriver.exe
package zooAdopTestsRepo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class AbstractPage {
public WebDriver driver;
public AbstractPage(WebDriver driver)
{
this.driver = driver;
}
public LandingPage navigatetoWebsite() throws InterruptedException
{
//public WebDriver driver = null;
//System.setProperty(“webdriver.gecko.driver”, “C://geckodriver//geckodriver.exe”);
//System.setProperty(“webdriver.gecko.driver”, “C://geckodriver//geckodriver.exe”);
System.setProperty(“webdriver.chrome.driver”, “C:\\Program Files\\chromedriver_win32\\chromedriver.exe”);
driver =new ChromeDriver();
Thread.sleep(5000);
String url = “http://www.thetestroom.com/webapp/index.html”;
//driver.navigate().to(“http://www.thetestroom.com/webapp/index.html”);
driver.get(“url”);
return new LandingPage(driver);
}
Hi above is my code , i am having the same error in my cucumber project
—————————
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
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
any solution on this problem ?
Hi I am facing the same issue and the path I have copied is correct please check the code and help me out :
package com.First;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
public class First_BrowserTest {
@Test
public void f() {
System.setProperty(“chrome.driver.chrome”,”C:\\Users\\swathy.kothakota\\Desktop\\selenium\\chromedriver.exe”);
WebDriver driver=new ChromeDriver();
driver.get(“https://partnergw.antheminc.com/”);
}
}
Error:
[RemoteTestNG] detected TestNG version 6.13.1
FAILED: f
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:754)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:339)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at com.First.First_BrowserTest.f(First_BrowserTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:571)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:707)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:979)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1116)
at org.testng.TestNG.runSuites(TestNG.java:1028)
at org.testng.TestNG.run(TestNG.java:996)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================
By Nils…..very nice help thank you
package newpackage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class MyClass {
public static void main(String[] args) {
System.setProperty(“Webdriver.chrome.driver”,”C:\\Users\\RamAravind\\workspace\\WebDriver\\src\\drivers\\chromedriver.exe”);
WebDriver driver=new ChromeDriver();
driver.get(“https://www.google.co.in/”);
}
}
I m getting same error 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.(ChromeDriver.java:123)
at newpackage.MyClass.main(MyClass.java:12)
please give me a solution, I will post my code what error is coming
please find out the solution.
code:
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class sample{
public static void main(String[] args) {
System.setProperty(“webdriver.chromedriver.driver”, “C://Users//Jai//Downloads//ChromeSetup.exe”);
WebDriver driver = new ChromeDriver();
driver.get(“http://www.cit.edu.in”);
List links = driver.findElements(By.xpath(“//a”));
int linkCount = links.size();
System.out.println(“Total Number of link count on webpage = ” + linkCount);
List allElements = driver.findElements(By.xpath(“//*”));
int elementsCount = allElements.size();
driver.quit();
}}
In System.setProperty( “webdriver.chrome.driver”, “C:/Your/Path/to/chromedriver.exe”) —- why webdriver.chrome.driver is used .can you please help me understand