• <bdo id='2bsju'></bdo><ul id='2bsju'></ul>

        <legend id='2bsju'><style id='2bsju'><dir id='2bsju'><q id='2bsju'></q></dir></style></legend>

        <small id='2bsju'></small><noframes id='2bsju'>

      1. <tfoot id='2bsju'></tfoot>
        <i id='2bsju'><tr id='2bsju'><dt id='2bsju'><q id='2bsju'><span id='2bsju'><b id='2bsju'><form id='2bsju'><ins id='2bsju'></ins><ul id='2bsju'></ul><sub id='2bsju'></sub></form><legend id='2bsju'></legend><bdo id='2bsju'><pre id='2bsju'><center id='2bsju'></center></pre></bdo></b><th id='2bsju'></th></span></q></dt></tr></i><div id='2bsju'><tfoot id='2bsju'></tfoot><dl id='2bsju'><fieldset id='2bsju'></fieldset></dl></div>
      2. 线程“main"中的异常java.lang.IllegalStateException:驱动程序可执行文件的路

        时间:2023-07-13

        <small id='ioKCj'></small><noframes id='ioKCj'>

        • <bdo id='ioKCj'></bdo><ul id='ioKCj'></ul>
          <tfoot id='ioKCj'></tfoot>

          • <i id='ioKCj'><tr id='ioKCj'><dt id='ioKCj'><q id='ioKCj'><span id='ioKCj'><b id='ioKCj'><form id='ioKCj'><ins id='ioKCj'></ins><ul id='ioKCj'></ul><sub id='ioKCj'></sub></form><legend id='ioKCj'></legend><bdo id='ioKCj'><pre id='ioKCj'><center id='ioKCj'></center></pre></bdo></b><th id='ioKCj'></th></span></q></dt></tr></i><div id='ioKCj'><tfoot id='ioKCj'></tfoot><dl id='ioKCj'><fieldset id='ioKCj'></fieldset></dl></div>
            • <legend id='ioKCj'><style id='ioKCj'><dir id='ioKCj'><q id='ioKCj'></q></dir></style></legend>
                <tbody id='ioKCj'></tbody>

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

                  问题描述

                  线程main"中的异常 java.lang.IllegalStateException :驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置;有关详细信息,请参阅 https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.最新版本可从 http://chromedriver.storage.googleapis.com/index.html 下载在 com.google.common.base.Preconditions.checkState(Preconditions.java:199)在 org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)在 org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)在 org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137) 在 org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)在 org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88) 在 org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)在 practice_locators.DatePicker.main(DatePicker.java:11)

                  这是我的代码:

                  包practice_locators;导入 org.openqa.selenium.WebDriver;导入 org.openqa.selenium.chrome.ChromeDriver;公共类 DatePicker {公共静态无效主要(字符串[]参数){WebDriver driver = new ChromeDriver();System.setProperty("WebDriver.Chrome.driver", "E:\chromedriver.exe");driver.get("https://www.google.com");}}

                  解决方案

                  错误说明了一切:

                  线程main"中的异常 java.lang.IllegalStateException :驱动程序可执行文件的路径必须由 webdriver.chrome.driver 系统属性设置;有关详细信息,请参阅 https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.最新版本可从 http://chromedriver.storage.googleapis.com/index.html 下载在 com.google.common.base.Preconditions.checkState(Preconditions.java:199)

                  错误中的以下短语暗示包含 webdriver.chrome.driver

                  的行中存在错误

                  错误可能是以下任何一种:

                  • 系统类方法 setProperty()(包括序列):

                    System.setProperty()

                    <块引用>

                    这一行应该是您脚本中的第一行.

                  • 指定的 :

                    "WebDriver.Chrome.driver"

                  • 字段出错:

                    "E:\chromedriver.exe"

                    <块引用>

                    您必须通过以下任一选项传递 WebDriver 的绝对路径:

                    • 转义反斜杠 (\) 例如"C:\path\to\chromedriver.exe"
                    • 单正斜杠 (/) 例如"C:/path/to/chromedriver.exe"

                  您的代码似乎有如下两个问题:

                  • 第一个问题是指定 Key 而不是 "WebDriver.Chrome.driver" 应该是 "webdriver.chrome.driver"如下:

                    System.setProperty("webdriver.chrome.driver", "E:\chromedriver.exe");

                  • 第二个问题是在 序列 提到 Key "webDriver.chrome.driver" 在你的程序中应该在 WebDriver driver = new ChromeDriver(); 之前如下:

                    System.setProperty("WebDriver.Chrome.driver", "E:\chromedriver.exe");WebDriver driver = new ChromeDriver();driver.get("https://www.google.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:199)  
                  at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)  
                  at org.openqa.selenium.chrome.ChromeDriverService.access$0(ChromeDriverService.java:1)  
                  at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)   at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)   
                  at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)     at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)    
                  at practise_locators.DatePicker.main(DatePicker.java:11)
                  

                  Here is my code:

                  package practise_locators;
                  
                  import org.openqa.selenium.WebDriver;
                  import org.openqa.selenium.chrome.ChromeDriver;
                  
                  public class DatePicker {
                  
                      public static void main(String[] args){
                          WebDriver driver = new ChromeDriver();
                          System.setProperty("WebDriver.Chrome.driver", "E:\chromedriver.exe");
                          driver.get("https://www.google.com");
                      }
                  
                  }
                  

                  解决方案

                  The error says it all :

                  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:199) 
                  

                  The following phrases from the error implies that there is an error in the line containing webdriver.chrome.driver

                  The error can be either of the following :

                  • Error in the System Class Method setProperty()(including sequence) :

                    System.setProperty()
                    

                    This line should be the very first line in your script.

                  • Error in the specified Key :

                    "WebDriver.Chrome.driver"
                    

                  • Error in the Value field :

                    "E:\chromedriver.exe"
                    

                    You have to pass the absolute path of the WebDriver through either of the following options :

                    • Escaping the back slash (\) e.g. "C:\path\to\chromedriver.exe"
                    • Single forward slash (/) e.g. "C:/path/to/chromedriver.exe"

                  Your code seems to be having two issues as follows :

                  • First issue is in specifying the Key which instead of "WebDriver.Chrome.driver" should have been "webdriver.chrome.driver" as follows :

                    System.setProperty("webdriver.chrome.driver", "E:\chromedriver.exe");
                    

                  • Second issue is in the sequence of mentioning the Key "webDriver.chrome.driver" in your program which should be before WebDriver driver = new ChromeDriver(); as follows :

                    System.setProperty("WebDriver.Chrome.driver", "E:\chromedriver.exe");
                    WebDriver driver = new ChromeDriver();
                    driver.get("https://www.google.com");
                    

                  这篇关于线程“main"中的异常java.lang.IllegalStateException:驱动程序可执行文件的路径必须由:系统属性设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:'UnexpectedTagNameException' 和 Element 应该是“select&qu 下一篇:如何在 webdriver 中捕获页面发出的所有请求?Browsermob有什么替代品吗?

                  相关文章

                    <bdo id='LYvqZ'></bdo><ul id='LYvqZ'></ul>
                1. <i id='LYvqZ'><tr id='LYvqZ'><dt id='LYvqZ'><q id='LYvqZ'><span id='LYvqZ'><b id='LYvqZ'><form id='LYvqZ'><ins id='LYvqZ'></ins><ul id='LYvqZ'></ul><sub id='LYvqZ'></sub></form><legend id='LYvqZ'></legend><bdo id='LYvqZ'><pre id='LYvqZ'><center id='LYvqZ'></center></pre></bdo></b><th id='LYvqZ'></th></span></q></dt></tr></i><div id='LYvqZ'><tfoot id='LYvqZ'></tfoot><dl id='LYvqZ'><fieldset id='LYvqZ'></fieldset></dl></div>

                  <tfoot id='LYvqZ'></tfoot>
                    <legend id='LYvqZ'><style id='LYvqZ'><dir id='LYvqZ'><q id='LYvqZ'></q></dir></style></legend>

                    <small id='LYvqZ'></small><noframes id='LYvqZ'>