java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置 [英] java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property

查看:29
本文介绍了java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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)

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

Any help is highly appreciated. Thanks in advance

推荐答案

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

Assuming the chromedriver.exe is stored at your desktop, you need to make a couple of changes as follows:

  • 您需要在 Webdriver.chrome.driver 中将大写的 W 替换为小写的 w.
  • 当您使用 系统时,假设chromedriver.exe 放置在您的桌面 ypu 需要附加 WebDriver 变体名称以及 绝对路径 内的扩展名网络驱动程序.
  • 这行代码实际上是:

  • You need to replace the uppercase W with lower case w within Webdriver.chrome.driver.
  • As you are on windows system, presuming chromedriver.exe is placed in your desktop ypu need to append the WebDriver variant name along with the extension within the absolute path of the WebDriver.
  • Effectively the line of code will be:

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

注意:webdriver.chrome.driver 需要以小写字母开头.

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

这篇关于java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆