线程“main”中的异常java.lang.IllegalStateException:在Ubuntu上运行Selenium Test时,驱动程序可执行文件不存在 [英] Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist while running Selenium Test on Ubuntu

查看:139
本文介绍了线程“main”中的异常java.lang.IllegalStateException:在Ubuntu上运行Selenium Test时,驱动程序可执行文件不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在eclipse中试过这段代码:

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); 
    }
}

执行时出现此错误:

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

如何在ubuntu中设置geckodriver位置?

How can i set geckodriver location in ubuntu?

推荐答案

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

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






更新



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


Update

As you are still seeing the error ensure that :


  1. GeckoDriver 出现在指定位置。

  2. GeckoDriver 具有非root用户的可执行权限。 (chmod 777)

  3. 以非root用户身份执行 @Test

  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.

这篇关于线程“main”中的异常java.lang.IllegalStateException:在Ubuntu上运行Selenium Test时,驱动程序可执行文件不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆