【问题标题】:Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist error using Selenium ChromeDriver and Java [duplicate]线程“main”java.lang.IllegalStateException中的异常:驱动程序可执行文件必须存在使用Selenium ChromeDriver和Java的错误[重复]
【发布时间】:2022-01-01 14:03:16
【问题描述】:

我正面临 java.lang.IllegalStateException 执行我的代码。

代码试验:

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

public class seleniumintroduction {

    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver","C:\\Users\\ATIF\\OneDrive\\Desktop\\Selenium Course\\chromedriver_win32.exe");
        WebDriver driver=new ChromeDriver();
    }
 }

我看到的错误:

Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist: C:\Users\ATIF\OneDrive\Desktop\Selenium Course\chromedriver_win32.exe

【问题讨论】:

    标签: java selenium google-chrome selenium-webdriver selenium-chromedriver


    【解决方案1】:

    虽然下载的 zip 文件名是 chromedriver_win32.zip,但是一旦你解压 ChromeDriver 它是 chromedriver.exe

    所以你需要换行:

    System.setProperty("webdriver.chrome.driver","C:\\Users\\ATIF\\OneDrive\\Desktop\\Selenium Course\\chromedriver_win32.exe");
    

    作为

    System.setProperty("webdriver.chrome.driver","C:\\Users\\ATIF\\OneDrive\\Desktop\\Selenium Course\\chromedriver.exe");
    

    【讨论】:

      猜你喜欢
      • 2019-05-06
      • 2018-06-09
      • 2018-08-27
      • 2022-01-22
      • 1970-01-01
      • 2020-03-13
      • 2018-09-29
      • 1970-01-01
      相关资源
      最近更新 更多