简体   繁体   中英

Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist error using Selenium Java

Error:

Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist

Code trials:

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

public class Hello {
                
    public static void main(String[] args) {            
        System.setProperty("webdriver.gecko.driver", "‪C:\\Users\\91831\\OneDrive\\Desktop\\eclipse-workspace\\geckodriver.exe");
        System.out.println("Hello");
        WebDriver driver = new FirefoxDriver();
        driver.get("http:\\www.amazon.in");
    }    
}

This error message...

Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist

...implies that the WebDriver executable doesn't exists at the mentioned location.


You have mentioned:

System.setProperty("webdriver.gecko.driver", "‪C:\\Users\\91831\\OneDrive\\Desktop\\eclipse-workspace\\geckodriver.exe");

As you are using operating system, ensure that you have downloaded GeckoDriver with .zip extension from the release location , unzipped the executable binary and placed geckodriver.exe within C:\\Users\\91831\\OneDrive\\Desktop\\eclipse-workspace sub-directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM