gpt4 book ai didi

linux - 无法在 Linux 中的 Jenkins 上执行 chrome 驱动程序

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:46:24 26 4
gpt4 key购买 nike

我有在 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 和 mac 机器中,我们没有像在 windows 中那样的 exe 文件,因此您需要使用 chmod +x 命令使驱动程序可执行。请进入chromedriver所在的路径,然后执行chmod +x命令。

在你的情况下应该是:

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

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

关于linux - 无法在 Linux 中的 Jenkins 上执行 chrome 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54765971/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com