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
5,204 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,230 points
3,322 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,140 points
15,891 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,500 points
13,772 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,187 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,263 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,901 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
198,275 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,150 points
15,967 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