Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“线程中的异常”;“主要”;java.lang.IllegalStateException:在Ubuntu上运行Selenium测试时,驱动程序可执行文件不存在_Java_Selenium_Ubuntu_Selenium Webdriver_Geckodriver - Fatal编程技术网

“线程中的异常”;“主要”;java.lang.IllegalStateException:在Ubuntu上运行Selenium测试时,驱动程序可执行文件不存在

“线程中的异常”;“主要”;java.lang.IllegalStateException:在Ubuntu上运行Selenium测试时,驱动程序可执行文件不存在,java,selenium,ubuntu,selenium-webdriver,geckodriver,Java,Selenium,Ubuntu,Selenium Webdriver,Geckodriver,我在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/jarselen

我在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); 
    }
}
执行时,我遇到了以下错误:

Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: /root/Desktop/jarselenium/geckodriver.exe
如何在ubuntu中设置geckodriver的位置

当您使用基于Linux的系统时,在指定GeckoDriver的绝对路径时,必须修剪扩展部分,即
.exe
部分,如下所示:

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

更新 由于您仍然看到错误,请确保:

  • GeckoDriver位于指定位置
  • GeckoDriver对非root用户具有可执行权限。(chmod 777)
  • 以非root用户身份执行
    @Test

  • 线程“main”java.lang.IllegalStateException中出现相同的错误异常:驱动程序可执行文件不存在:/root/Desktop/jarselenium/geckodrive。@sanjan签出我的答案更新并告诉我状态。不要错过
    geckodriver
    .thz的fag端的
    e
    。但是//driver.manage().timeouts().implicitlyWait(25,TimeUnit.SECONDS);如果启用该行时间单位,则为error@sanjan从您的
    @测试中完全删除
    隐式等待
    ,因为它不再有效,而且从长远来看,您只能使用WebDriverWait