gpt4 book ai didi

java.lang.IllegalStateException : The path to the driver executable must be set by the webdriver. chrome.driver 系统属性

转载 作者:行者123 更新时间:2023-11-29 08:32:46 29 4
gpt4 key购买 nike

这是我的代码:

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.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://qaclickacademy.com");

}

}

出现以下错误:

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:754)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
at Basics.invokegoogle.main(invokegoogle.java:12)

非常感谢任何帮助。提前致谢

最佳答案

假设 chromedriver.exe 存储在您的桌面上,您需要进行如下几项更改:

  • 您需要将 Webdriver.chrome.driver 中的大写 W 替换为小写 w
  • 因为你在 系统,假设 chromedriver.exe 位于您的桌面,您需要在 绝对路径 中附加 WebDriver 变体名称和扩展WebDriver
  • 有效的代码行将是:

    System.setProperty("webdriver.chrome.driver", "C:\\Users\\sravani\\Desktop\\chromedriver.exe");

Note: webdriver.chrome.driver needs to start with lowercase letter.

关于java.lang.IllegalStateException : The path to the driver executable must be set by the webdriver. chrome.driver 系统属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46587942/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com