简体   繁体   English

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

[英]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 :我在 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?如何在 ubuntu 中设置 geckodriver 位置?

As you are using Linux based System while specifying the absolute path of the GeckoDriver you have to trim the extension part ie .exe part as follows :当您在指定GeckoDriver的绝对路径时使用基于 Linux 的系统时,您必须修剪扩展部分,即.exe部分,如下所示:

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. GeckoDriver存在于指定位置。
  2. GeckoDriver is having executable permission for non-root users. GeckoDriver对非 root 用户具有可执行权限。 (chmod 777) (chmod 777)
  3. Execute your @Test as a non-root user.以非 root 用户身份执行@Test

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 线程“主”java.lang.IllegalStateException 中的异常:驱动程序可执行文件必须存在错误,使用 Selenium 和 Java - Exception in thread "main" java.lang.IllegalStateException: The driver executable must exist error using Selenium and Java 线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件是一个目录 - Exception in thread “main” java.lang.IllegalStateException: The driver executable is a directory java.lang.IllegalStateException:驱动程序可执行文件不存在:尝试通过Selenium,ChromeDriver和Chrome执行测试时 - java.lang.IllegalStateException: The driver executable does not exist: while trying to execute tests through Selenium, ChromeDriver and Chrome java.lang.IllegalStateException: 驱动程序可执行文件不存在 chrome 驱动程序 - java.lang.IllegalStateException: The driver executable does not exist chrome driver Geckodriver 错误:线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 - Geckodriver Error: Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by 线程“main”中的异常 java.lang.IllegalStateException:驱动程序可执行文件的路径必须由:系统属性设置 - Exception in thread "main" java.lang.IllegalStateException:The path to the driver executable must be set by the : system property java.lang.IllegalStateException:驱动程序可执行文件不存在 - java.lang.IllegalStateException: The driver executable does not exist 使用Selenium的线程“main”java.lang.IllegalStateException中的异常 - Exception in thread “main” java.lang.IllegalStateException for using Selenium 线程“ main”中的异常java.lang.IllegalStateException:驱动程序可执行文件的路径必须由webdriver.gecko.driver系统设置 - Exception in thread “main” java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system “ java.lang.IllegalStateException:驱动程序可执行文件不存在”报告奇怪的附加路径 - “java.lang.IllegalStateException: The driver executable does not exist” reports odd appended path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM