Mac OSX-IllegalStateException:该驱动程序不可执行: [英] Mac OSX - IllegalStateException: The driver is not executable:
问题描述
我是Mac OSX的新手.从git下载了我的Robotframework(Selenium& Java)项目,并尝试在本地执行代码,从而收到以下错误.
Im new to Mac OSX. Downloaded my Robotframework(Selenium & Java) project from git and tried to execute the code locally wherein I received the below error.
套房设置失败: IllegalStateException:该驱动程序不可执行:/Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
Suite setup failed: IllegalStateException: The driver is not executable: /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
为纠正此问题,我按照以下步骤操作,但没有成功.
To rectify this issue, I followed the below but it didnt work.
- 将selenium-java和独立版本从2.53.1升级到3.4.0.
- 指定给Users/roja/automation的驱动程序路径
- Chromedriver从2.31升级到2.33
- 即使在上述例外中指定的路径中,相同的驱动程序版本也会更新.
- 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也保存在相同的路径中.请澄清并提供解决方案.
Also Im unsure why the path is defaulted to /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
.
My git projects are saved in the path usr/local/git/testautomation and chromedriver also saved in the same. please clarify and provide me a solution.
下面为启动浏览器而编写的代码,
Below code written for launching the browser,
public void LaunchBrowser() throws InterruptedException {
System.setProperty("Webdriver.chrome.driver", "/Users/roja/Automation/chromedriver_osx");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
推荐答案
错误IllegalStateException: The driver is not executable: /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
说明了一切.您必须进行如下4个更改:
The error IllegalStateException: The driver is not executable: /Users/roja/Documents/GitHub/testautomation/chromedrivers/chromedriver_osx
says it all. You have to make exactly 4 changes as follows :
-
将
Webdriver.chrome.driver
更改为:
webdriver.chrome.driver
更改/Users/roja/Automation/chromedriver_osx
,因为我们需要包含webdriver binary
的名称,即 chromedriver
作为 value
:
Change /Users/roja/Automation/chromedriver_osx
as we need to include the name of the webdriver binary
i.e. chromedriver
as a value
:
/Users/roja/Automation/chromedriver_osx/chromedriver
将driver = new ChromeDriver();
更改为:
Change driver = new ChromeDriver();
as :
WebDriver driver = new ChromeDriver();
删除不需要的throws InterruptedException
,以使代码简洁明了.
Remove unwanted throws InterruptedException
to keep your code short and simple.
这篇关于Mac OSX-IllegalStateException:该驱动程序不可执行:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!