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

﹥>﹥吖頭↗ 提交于 2019-12-17 06:18:13

问题


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?


回答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.


来源:https://stackoverflow.com/questions/49920781/exception-in-thread-main-java-lang-illegalstateexception-the-driver-executabl

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