所以我正在尝试学习 Selenium 并遇到了问题。 无法运行 chromedriver。
错误:
Exception in thread "main" java.lang.IllegalStateException: The driver is not executable: /Users/Roberto/Documents/EclipseProjects/MansPirmaisSelenium/lib/chromedriver
代码:
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+"//lib//chromedriver");
WebDriver chromeDriver = new ChromeDriver();
chromeDriver.get("http://www.google.lv");
最佳答案
我假设您刚刚下载了 chromedriver 应用程序,在这种情况下您只需 mark it as executable在 Unix 中:
chmod +x chromedriver
如果您可以自己从终端运行应用程序,那么 WebDriver 也应该可以。
顺便说一句,我不会在您的项目中包含 chromedriver
:
- 您会想在其他项目中重复使用它
- 根据documentation :
include the ChromeDriver location in your PATH environment variable
关于java - Java 中的 Chromedriver 不可执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35509076/