Mac OSX - IllegalStateException: The driver is not executable:

瘦欲@ 提交于 2019-11-26 14:51:10

问题


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.

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.

  1. Upgraded the selenium-java and standalone version from 2.53.1 to 3.4.0.
  2. Driver path specified to Users/roja/automation
  3. Chromedriver upgraded from 2.31 to 2.33
  4. And the same driver version updated even in the path specified in the exception above.

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();
}

回答1:


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 :

  • Change Webdriver.chrome.driver as :

    webdriver.chrome.driver
    
  • 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
    
  • Change driver = new ChromeDriver(); as :

    WebDriver driver = new ChromeDriver();
    
  • Remove unwanted throws InterruptedException to keep your code short and simple.




回答2:


FYI I had to do the solution proposed by varunrao321: Navigate to the folder containing chromedriver and run chmod +x chromedriver




回答3:


Another solution that worked for me. Navigate to the folder containing chromedriver and run "chmod +x chromedriver"




回答4:


I tried giving full permission to the chromedriver and it works fine.

chmod +x chromedriver

or

chmod 777 chromedriver



回答5:


@debanjan already explain good expalaination to you, I am just giving you correct code:

public void LaunchBrowser() throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "/Users/roja/Automation/chromedriver_osx/chromedriver");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
}



回答6:


It may be due to the permission access. Download the chrome driver using http://chromedriver.chromium.org/downloads and then give path.

Example:

System.setProperty("webdriver.chrome.driver","/Users/xyz/Downloads/chromedriver");       



回答7:


The way I solved this problem was by importing the chromedriver with right click>Import instead of dragging it to the folder.

I don't know exactly why, but it worked.




回答8:


For me, it was the last driver that was not working with the chrome version installed on my macOS mojave. I was forced to install last version of google chrome, then it worked.



来源:https://stackoverflow.com/questions/47306190/mac-osx-illegalstateexception-the-driver-is-not-executable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!