webdrivermanager: ChromeDriver error: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property;
I have set up webdrivermanager as per instructions given in the readme. On running a test, the driver instantiation throws an error:
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:199) at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109) 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:296) at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116) at AccountQuery.start(AccountQuery.java:37) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:86) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:514) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:215) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:142) at org.testng.TestRunner.beforeRun(TestRunner.java:656) at org.testng.TestRunner.run(TestRunner.java:624) at org.testng.SuiteRunner.runTest(SuiteRunner.java:366) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:361) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:319) at org.testng.SuiteRunner.run(SuiteRunner.java:268) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244) at org.testng.TestNG.runSuitesLocally(TestNG.java:1169) at org.testng.TestNG.run(TestNG.java:1064) at Main.main(Main.java:16)
What am I doing wrong? Code snippet is given below:
public class AccountQuery {
static WebDriver driver;
private static final Logger log = Logger.getLogger("AccountQuery");
private StringBuffer verificationErrors = new StringBuffer();
@BeforeClass
public static void setupClass() {
ChromeDriverManager.getInstance().setup();
}
@BeforeTest
public void start() {
try{
driver = new ChromeDriver();
} catch (Exception ex){
log.info("Exception while instantiating driver. ",ex);
}
}
@Test(dataProvider="ConfigData",dataProviderClass=TestDataProvider.class)
public void FirstLogin(Configuration config) throws InterruptedException {
driver.manage().window().maximize();
driver.get(config.getString("URL"));
driver.findElement(By.id("username")).sendKeys(config.getString("username"));
// other similar lines omitted
}
@AfterClass(alwaysRun = true)
public void tearDown() throws Exception {
if (driver != null) {
driver.quit();
}
}
}
Maven dependencies:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>1.4.5</version>
</dependency>
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (1 by maintainers)
Add
in Given step def
Example,
@1230priya - I have written using eclipse IDE. Add External JAR’s without fail. Always worked for me both with Firefox and ChromeDriver. Try this. import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Example{ public static void main(String[] args) { System.setProperty(“webdriver.chrome.driver”, “D:\chromedriver_win32\chromedriver.exe”); WebDriver driver = new ChromeDriver(); driver.get(“https://google.com”); } }
@britka : I got it solved thought of sharing the solver : System.setProperty(“webdriver.chrome.driver”, “C:\Users\Ampacattu\Downloads\chromedriver_win32\chromedriver.exe”);
Hi All,
We have been using the WebDriverManager for awhile now without any issues. For some reason after the latest version of Chrome 101.0.4951.41 installed, on one set of tests we are getting the error below:
We have multiple test project setup the same way. Our GebConfig.Groovy is setup to setup the driver, as seen below:
We’ve never had to specify the location of the driver, using System.setProperty, in the past, that is the point of using the manager. I can’t seem to figure out what the difference is between this project and others that work that are setup the same way. Any suggestions on troubleshooting?
Add External JAR’s without fail and try this. package com.java_testing;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver;
public class Test {
}
@britka : I am getting an error for ChromeDriverManager.getInstance().setup();
Error: ChromeDriverManager cannot be resolved
It appears that testng annotations get invoked in a slightly different order - one that is confusing to many (including myself). It is:
Pushing
ChromeDriverManager.getInstance().setup();to@BeforeTestsolved the issue. Thanks for a great utility 👍 👍 👍 !!