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?
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 :
- GeckoDriver is present in the specified location.
- GeckoDriver is having executable permission for non-root users. (chmod 777)
- Execute your
@Test
as a non-root user.
来源:https://stackoverflow.com/questions/49920781/exception-in-thread-main-java-lang-illegalstateexception-the-driver-executabl