线程“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

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

问题描述

我在 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?

推荐答案

当您使用 Linux based System 时,同时指定 GeckoDriver 的绝对路径,您必须修剪扩展部分即.exe部分如下:

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 存在于指定位置.
  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 测试时驱动程序可执行文件不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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