how to solve java lang IllegalStateException

0 votes
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 testing.Demo.main(Demo.java:16)
Jun 24, 2019 in Selenium by yogesh
• 120 points
2,700 views

1 answer to this question.

0 votes

Include the below line in your code before creating the browser instance and mention the path where the chromedriver exists. It should work.

System.setProperty("webdriver.chrome.driver","<path to chrome driver>\chromedriver.exe");

If your chromedriver is in the C drive under the Driver folder, then the code should be like this:

System.setProperty("webdriver.chrome.driver","C:\Driver\chromedriver.exe");
answered Jun 24, 2019 by John
yes , i included that line

this is the script what iam going to run

 

package testing;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Demo
{

    public static void main(String[] args)
    {
        
    System.setProperty("Webdriver.Chrome.driver","C:\\Users\\Yogesha\\Downloads\\chromedriver.exe");
        WebDriver driver=new ChromeDriver();
        driver.get("https://Google.com");
    }

}

iam not getting why iam getting this error

There's a typo in your code. 

The code should be:

System.setProperty("webdriver.chrome.driver","<path to chrome driver>\chromedriver.exe");

with all small-case letters but you are using some upper-case letters:

System.setProperty("Webdriver.Chrome.driver","C:\\Users\\Yogesha\\Downloads\\chromedriver.exe");
Now iam able to run the script Thanks and regards .....

Related Questions In Selenium

0 votes
1 answer

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: how to solve it?

Your query is similar to https://www.edureka.co/community/46570/illegalstateexception-executable-automation-chromedriver Check it ...READ MORE

answered Nov 6, 2020 in Selenium by Sirajul
• 59,050 points
426 views
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,040 points
4,032 views
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,520 points
5,067 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,010 points
5,806 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,890 points
3,574 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 2, 2020 in Selenium by Sri
• 3,010 points
4,308 views
+11 votes
16 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
138,242 views
+1 vote
2 answers

How to get the title of a webpage using Selenium Java?

Essentially, driver.getTitle(); function can be used to ...READ MORE

answered Dec 17, 2018 in Selenium by Vardhan
• 13,200 points
10,022 views