我是 Mac OSX 新手。从 git 下载了我的 Robotframework(Selenium 和 Java)项目并尝试在本地执行代码,其中我收到了以下错误。
套件设置失败: IllegalStateException:驱动程序不可执行:/Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
为了解决这个问题,我按照以下方法操作,但没有成功。
- Upgraded the selenium-java and standalone version from 2.53.1 to 3.4.0.
- Driver path specified to Users/roja/automation
- Chromedriver upgraded from 2.31 to 2.33
- And the same driver version updated even in the path specified in the exception above.
我也不确定为什么路径默认为 /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
。
我的git项目保存在usr/local/git/testautomation路径中,chromedriver也保存在同一路径中。请澄清并给我一个解决方案。
下面为启动浏览器编写的代码,
public void LaunchBrowser() throws InterruptedException {
System.setProperty("Webdriver.chrome.driver", "/Users/roja/Automation/chromedriver_osx");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
最佳答案
Quick installation最新的 ChromeDriver
安装最新版本ChromeDriver :
使用 Homebrew 的 Mac 用户:
brew tap homebrew/cask && brew cask install chromedriver
原始回答于 2017 年 11 月 15 日 12:04
错误IllegalStateException:驱动程序不可执行:/Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
说明了一切。您必须进行如下 4 项更改:
将
Webdriver.chrome.driver
更改为:webdriver.chrome.driver
更改
/Users/roja/Automation/chromedriver_osx
,因为我们需要包含webdriver二进制文件
的名称,即chromedriver
作为值
:/Users/roja/Automation/chromedriver_osx/chromedriver
将
driver = new ChromeDriver();
更改为:WebDriver driver = new ChromeDriver();
删除不需要的
抛出 InterruptedException
以保持代码简短。
关于java - Mac OSX - IllegalStateException : The driver is not executable:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60606521/