Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist while running Selenium Test on Ubuntu

I have tried this code in eclipse :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class auto {

    public static void main(String[] args) {
        System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver.exe");
        WebDriver driver = new FirefoxDriver();
        driver.manage().window().maximize();
        driver.get("https://www.easybooking.lk/login");
        //driver.manage().timeouts().implicitlyWait(25, TimeUnit.SECONDS); 
    }
}

On execution I got this error :

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /root/Desktop/jarselenium/geckodriver.exe

How can i set geckodriver location in ubuntu?


Solution 1:

As you are using Linux based System while specifying the absolute path of the GeckoDriver you have to trim the extension part i.e. .exe part as follows :

System.setProperty("webdriver.gecko.driver", "/root/Desktop/jarselenium/geckodriver");

Update

As you are still seeing the error ensure that :

  1. GeckoDriver is present in the specified location.
  2. GeckoDriver is having executable permission for non-root users. (chmod 777)
  3. Execute your @Test as a non-root user.