【问题标题】:Unable to execute the chrome driver on Jenkins in Linux无法在 Linux 中的 Jenkins 上执行 chrome 驱动程序
【发布时间】:2019-02-19 12:06:44
【问题描述】:

我有在 Linux 机器上运行的 jenkins,每当我尝试运行以下脚本时,它都会失败并说驱动程序不可执行。

  java.lang.IllegalStateException: The driver is not executable: /COMPLIANCE-48/workspace/AutoProfile_Exec/Driver/chromedriver
  at com.google.common.base.Preconditions.checkState(Preconditions.java:199)

代码:

        String getLocation=System.getProperty("chromePath");
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.addArguments("--headless");
        System.setProperty("webdriver.chrome.driver",getLocation);
        WebDriver iDriver = new ChromeDriver(chromeOptions);

下面是mvn命令

-U clean compile exec:java -DchromePath="${WORKSPACE}/Driver/chromedriver"

实际上,我已将 chromedriver 放在该特定路径中并将其作为参数传递。但不知道为什么它说驱动程序不可执行。

【问题讨论】:

    标签: linux selenium jenkins selenium-webdriver selenium-chromedriver


    【解决方案1】:

    在 linux 和 mac 机器中,我们没有 Windows 中的 exe 文件,因此您需要使用 chmod +x 命令使驱动程序可执行。请进入chromedriver所在的路径,然后执行chmod +x 命令。

    在你的情况下应该是:

    cd /COMPLIANCE-48/workspace/AutoProfile_Exec/Driver
    chmod +x chromedriver
    

    运行上述命令后,尝试运行代码,就可以了。

    【讨论】:

      【解决方案2】:

      添加到@Sameer Arora 答案,如果他的解决方案不能解决问题,请尝试将-DchromePath 更改为-Dwebdriver.chrome.driver,如下所示:

      -U clean compile exec:java -Dwebdriver.chrome.driver="${WORKSPACE}/Driver/chromedriver"
      

      并确保chromedriver 是可执行的驱动程序文件,而不是目录或其他文件。

      查看Mac OSX - IllegalStateException: The driver is not executable:了解更多信息。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-01-28
        • 2013-07-13
        • 2017-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多