Can't open chrome using selenium

I am using the following code to start the chrome driver:

import org.openqa.selenium.*;

import org.openqa.selenium.chrome.ChromeDriver;

public class TestClass 
{

    public static void main(String[] args){
        System.setProperty("webdriver.chrome.driver", "/Users/raisa/Documents/Selenium/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("http://www.google.com");
        driver.quit();
    }
}

      

But I am getting this error:

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /Users/raisa/Documents/Selenium/chromedriver.exe
    at com.google.common.base.Preconditions.checkState(Preconditions.java:177)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:117)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:112)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:89)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:117)
    at TestClass.main(TestClass.java:11)

      

I downloaded the latest chrome driver from http://chromedriver.storage.googleapis.com/index.html

+3


source to share


1 answer


I agree with the comments. On Mac OS, you wo n't need .exe

after chromedriver

.

In your example, you want to make it look as follows: /Users/raisa/Documents/Selenium/chromedriver

.



I also saw that this issue came about because the execute permissions were not set on the file. So double check the permissions of the file and also indicate that the file is in the specified actual path.

+2


source







All Articles