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 in Selenium by yogesh
• 120 points
232 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 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
0 votes
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,110 points
2,260 views
0 votes
1 answer

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,110 points
915 views
0 votes
1 answer
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,130 points
1,102 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
833 views
+9 votes
15 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,270 points
69,647 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
• 12,730 points
532 views