Home  >  Article  >  Java  >  How to Fix \"IllegalStateException: Webdriver.chrome.driver System Property Misconfigured\" Error in Java?

How to Fix \"IllegalStateException: Webdriver.chrome.driver System Property Misconfigured\" Error in Java?

Linda Hamilton
Linda HamiltonOriginal
2024-10-24 02:43:01360browse

How to Fix

Resolving "IllegalStateException: Webdriver.chrome.driver System Property Misconfigured" in Java

The exception "java.lang.IllegalStateException: The path to the driver executable must be set" indicates that the WebDriver setup is incorrect. To rectify this issue, follow these instructions:

Incorrect Property Name

Notice that in the code snippet provided, the property is misspelled as "Webdriver.chrome.driver" with uppercase "W". Correct this to "webdriver.chrome.driver" with lowercase "w".

Absolute Path and Extension

The error message suggests that the driver executable path is not specified properly. Ensure that you provide the absolute path to the chromedriver.exe executable file. For Windows systems, the path should include the file extension.

Corrected Code

Below is the corrected version of your code:

<code class="java">package Basics;

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

public class invokegoogle {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "C:\Users\sravani\Desktop\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("http://qaclickacademy.com");
    }

}</code>

Note:

  • The webdriver.chrome.driver property must start with lowercase letters.
  • Provide the absolute path to the chromedriver.exe executable file, including the file extension.

The above is the detailed content of How to Fix \"IllegalStateException: Webdriver.chrome.driver System Property Misconfigured\" Error in Java?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn