Roja
Roja

Reputation: 293

Mac OSX - IllegalStateException: The driver is not executable:

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

Upvotes: 8

Views: 22266

Answers (12)

varun raj
varun raj

Reputation: 21

Run this command in the folder where chromedriver is present: chmod +x chromedriver

Upvotes: 0

poojasingh
poojasingh

Reputation: 1

One More Solution :

  1. Visit : https://sites.google.com/a/chromium.org/chromedriver/downloads enter image description here

  2. Under "Current Releases" section, Click on Chrome driver link which is updated in your system.

  3. Automatically it will redirect to "https://chromedriver.storage.googleapis.com/index.html?path=" enter image description here

  4. Click on link for mac and unzip the folder.

  5. Now paste chromedriver.exe file into your project.

  6. And provide below mentioned code-

    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    public class SetChromeDriver {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir") + "/chromedriver");
            WebDriver driver = new ChromeDriver();
            driver.get("https://www.google.com/");
            driver.quit();
    
        }
    
    }
    
    

Upvotes: 0

Ritesh Kumar
Ritesh Kumar

Reputation: 11

Worked for me as well:

Step 1: Open terminal
Step 2: Navigate to the path folder containing chromedriver
Step 3: Run chmod +x chromedriver

Upvotes: 1

undetected Selenium
undetected Selenium

Reputation: 193078

Quick installation of the latest ChromeDriver

To install the latest version of ChromeDriver:

  • Mac users with Homebrew:

    brew tap homebrew/cask && brew cask install chromedriver
    

Original answered Nov 15 '17 at 12:04

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.

Upvotes: 6

E Kwong
E Kwong

Reputation: 31

You may install chromedriver by brew

brew cask install chromedriver

After that, as DebanjanB said, replace your

System.setProperty("Webdriver.chrome.driver","/Users/roja/Automation/chromedriver_osx");

with

System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");

It works for me.

Upvotes: 0

Luisa Hernández
Luisa Hernández

Reputation: 596

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.

Upvotes: 0

NilVS
NilVS

Reputation: 271

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.

Upvotes: 0

Anansha
Anansha

Reputation: 1

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");       

Upvotes: 0

anandxp
anandxp

Reputation: 66

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

chmod +x chromedriver

or

chmod 777 chromedriver

Upvotes: 5

Jorge
Jorge

Reputation: 305

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

Upvotes: 5

varunrao321
varunrao321

Reputation: 965

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

Upvotes: 2

iamsankalp89
iamsankalp89

Reputation: 4739

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

Upvotes: 0

Related Questions