英文:
Selenium Chrome Driver- Getting java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver
问题
以下是您提供的内容的翻译:
当我尝试使用以下代码启动 chromedriver 时,我遇到了 "java.lang.IllegalStateException: 必须通过 webdriver.chrome.driver 系统属性设置驱动程序可执行文件的路径;" 错误。
我的代码:
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
driver = new ChromeDriver();
我不想在那里放绝对路径,如果我放在那里,就无法实现可重用性的目的。
我已经检查过,我确信 chromedriver.exe 在设计的路径中,当我执行以下操作时:
System.out.println(System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
我不确定我在这里漏掉了什么... 请帮忙解决。
英文:
When I am trying to launch the chromedriver with below code . I am getting "java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; " error
My code:
System.setProperty("Webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
driver = new ChromeDriver();
I don't want to put absolute path there, if I put there it will not serve the purpose of reusability.
I have checked and I am sure that chromedriver.exe in the designed path and when I am doing
System.out.println(System.getProperty("user.dir")+"\\src\\test\\resources\\executables\\chromedriver.exe");
I am not sure what I am missing here .. Please help.
答案1
得分: 1
答案就隐藏在问题中。它说:“驱动程序可执行文件的路径必须由webdriver.chrome.driver系统属性设置”。不是Webdriver!是以小写w开头的webdriver!
英文:
The answer is hidden in the question. It says "The path to the driver executable must be set by the webdriver.chrome.driver system property". Not Webdriver! webdriver with a lowercase w!
答案2
得分: -1
好的。我找到问题所在:
Webdriver 中的 W 字母应该是小写的,所以以下代码适用于我。
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
driver = new ChromeDriver();
谢谢!
英文:
Ok. I got where is the issue is:
W letter in Webdriver was capital instead of small so below code working for me.
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "\\src\\test\\resources\\executables\\chromedriver.exe");
driver = new ChromeDriver();
thanks!
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论