java lang IllegalStateException Error after adding set property webdriver

0 votes

I am getting 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:199)

    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)

    at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)

    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 SeleniumFirefox.main(SeleniumFirefox.java:11)

Below is my code

 import org.openqa.selenium.WebDriver;

 import org.openqa.selenium.chrome.ChromeDriver;

 org.openqa.selenium.WebDriver;

 import org.openqa.selenium.WebElement;


 public class TestDemo {


   public static void main(String[] args) {

    // TODO Auto-generated method stub

    System.setProperty("webdriver.chromedriver.driver",

           "C://Users//balwinder//Desktop//chromedriver.exe");

    WebDriver driver = new ChromeDriver();


/*try {

    Thread.sleep(5000);

} catch(InterruptedException ex) {

    System.out.println(ex.getMessage());

}*/

   }}
Apr 19, 2018 in Selenium by Martin
• 4,320 points
19,932 views

3 answers to this question.

0 votes

set webdriver.chrome.driver instead of webdriver.chromedriver.driver

 System.setProperty("webdriver.chromedriver.driver",

           "C://Users//balwinder//Desktop//chromedriver.exe");

Should be:

System.setProperty("webdriver.chrome.driver",

           "C:\\Users\\balwinder\\Desktop\\chromedriver.exe");

OR

System.setProperty("webdriver.chrome.driver",

           "C:/Users/balwinder/Desktop/chromedriver.exe");

NOTE: it will work only if you are first setting the system property and then instantiating chrome driver.

answered Apr 19, 2018 by Vardy
• 2,360 points
This really helped. Thanks!
It worked for my whole class.
0 votes
import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class Demo2 {

       public static void main(String[] args) {

              // TODO Auto-generated method stub

              System.setProperty("webdriver.chrome.driver", "I:\\Bhasker-ShiroCode\\work\\chromedriver.exe");

              WebDriver driver = new ChromeDriver();

              driver.get("http://google.com");

       }

}

To avoid Error

webdriver.chrome.driver  ( should be in small letters )

have to give correct chromedriver.exe ( correct path )

Import all Selenium jars under class Path

answered Apr 16, 2019 by Bhasker vade

edited Apr 16, 2019 by Omkar
which jar files need to be associated?

@Mina, you need to import all the Selenium Standalone Server (latest version) and Selenium Server (latest version) Jar files into your project. You can download these files with any version of your choice from here: http://selenium-release.storage.googleapis.com/index.html

in the output, the cursor points to the search bar and is not searching for anything
Could you please post the code snippet you are using? Have you tried the solutions suggested in the answers?
0 votes
/*

System.setProperty("WebDriver.gecko.driver", "C:\\Users\\DELL\\Desktop\\GeckoDriver1\\geckodriver.exe");

WebDriver driver = new FirefoxDriver();

*/

    System.setProperty("WebDriver.Chrome.Driver", "C:\\Users\\DELL\\Desktop\\Chrome Driver\\chromedriver_win32.exe");

    WebDriver Driver= new ChromeDriver();

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 Seleniumpracticesessions.SeleniumWebdriverBasics.main(SeleniumWebdriverBasics.java:17)

I am trying to launch Mozilla FF/Chrome browser, however not able to launch the any of the specified browsers, above mentioned Exceptions are displayed, any one can help me..

answered May 1, 2019 by anonymous

Hi, your code is throwing these exceptions because you are setting the system property in a wrong manner, instead of using "WebDriver.Chrome.Driver", use "webdriver.chrome.driver" in System.setProperty() function. As, you should know that Java is a case-sensitive language, so if you set system properties in capital-case, system won't recognize the property and hence, will throw an exception. 

Similarly, for firefox driver, use "webdriver.gecko.driver" as system property.

Related Questions In Selenium

0 votes
1 answer

getting java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property

Hi Sivaranjani, to resolve your issue, Driver path ...READ MORE

answered Sep 3, 2019 in Selenium by Abha
• 28,140 points
15,792 views
0 votes
1 answer

Java.lang.CharSequence cannot be resolved error while using sendKeys() using Selenium Webdriver

You could try this, myElement .sendKeys(new String[] { ...READ MORE

answered Apr 4, 2018 in Selenium by Johnathon
• 9,090 points
4,747 views
0 votes
0 answers
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,567 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,084 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,178 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,840 views
+10 votes
17 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,360 points
197,673 views
0 votes
1 answer

Select an item from a dropdown list using Selenium WebDriver

Use this then it will work - new ...READ MORE

answered Apr 9, 2018 in Selenium by Vardy
• 2,360 points
7,730 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP