Selenium Chrome Driver- Getting java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver

huangapple go评论82阅读模式
英文:

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!

huangapple
  • 本文由 发表于 2020年8月23日 21:02:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63547285.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定