Selenium-jenkins与Linux。 “指定的Firefox二进制位置不存在或不是真实文件

我有一个Maven项目,可以在Windows上与本地Jenkins正常工作。 当我尝试从LINUX中设置的Jenkins运行相同的测试时,我收到Firefox驱动程序错误。

硒代码:

System.setProperty("webdriver.gecko.driver","/home/geckodriver");
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
options.setBinary("/usr/bin/firefox");
WebDriver driver = new FirefoxDriver(options);`

错误消息:

  

指定的firefox二进制位置不存在或不是真实文件:/ usr / bin / firefox   堆栈跟踪:   Stacktrace

     

java.lang.IllegalStateException:指定的firefox二进制位置不存在或不是真实文件:/ usr / bin / firefox           在com.google.common.base.Preconditions.checkState(Preconditions.java:504)           在org.openqa.selenium.firefox.Executable。(Executable.java:43)           在org.openqa.selenium.firefox.FirefoxBinary(FirefoxBinary.java:123)           在org.openqa.selenium.firefox.FirefoxOptions $ Binary.asBinary(FirefoxOptions.java:420)           在java.util.Optional.map(Optional.java:215)           在org.openqa.selenium.firefox.FirefoxOptions.getBinaryOrNull(FirefoxOptions.java:220)           在org.openqa.selenium.firefox.FirefoxOptions.getBinary(FirefoxOptions.java:216)           在org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:187)           在org.openqa.selenium.firefox.FirefoxDriver。(FirefoxDriver.java:147)           在Automationmodules.LaunchBrowser.getDriver(LaunchBrowser.java:37)           在Validations.LoginValidation.StartBrowser(LoginValidation.java:26)中

我也尝试不提供任何二进制文件。它不起作用

期待测试可以从詹金斯成功运行

wusliu 回答:Selenium-jenkins与Linux。 “指定的Firefox二进制位置不存在或不是真实文件

在我的Ubuntu上 /usr/bin/firefox -> ../lib/firefox/firefox.sh* 哪个开始

/usr/lib/firefox/firefox

由于我尚未更改Frirefox的安装位置,因此这似乎是默认位置,因此可能也对您有用。 所以尝试

options.setBinary("/usr/lib/firefox/firefox");
本文链接:https://www.f2er.com/3161505.html

大家都在问