【问题标题】:java.lang.IllegalStateException: The driver executable does not exist: /var/lib/jenkins/jobs/Ancon-Automation/workspace\src\main\...\chromedriver.exejava.lang.IllegalStateException:驱动程序可执行文件不存在:/var/lib/jenkins/jobs/Ancon-Automation/workspace\src\main\...\chromedriver.exe
【发布时间】:2018-08-17 06:09:39
【问题描述】:

单击构建时,我在 Jenkins 控制台 中遇到以下错误。但是,当我在我的 intelij IDE 中运行测试时,它运行时没有任何故障。是Jenkins这个问题还是chromedriver.exe的路径问题

[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[ERROR] Tests run: 38, Failures: 1, Errors: 0, Skipped: 37, Time elapsed: 2.237 s <<< FAILURE! - in TestSuite
[ERROR] SetUp(com.ancon.automation.tests.TenantsTest)  Time elapsed: 1.593 s  **<<< FAILURE!
java.lang.IllegalStateException: The driver executable does not exist: /var/lib/jenkins/jobs/Ancon-Automation/workspace\src\main\java\com\ancon\automation\webDriver\chromedriver.exe**
    at com.ancon.automation.tests.TenantsTest.SetUp(TenantsTest.java:62)

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   TenantsTest.SetUp:62 » IllegalState The driver executable does not exist: /var...
[INFO] 
[ERROR] Tests run: 16, Failures: 1, Errors: 0, Skipped: 15
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.616 s
[INFO] Finished at: 2018-08-17T09:56:58+05:30
[INFO] ------------------------------------------------------------------------
**[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project Ancon: There are test failures.
[ERROR]** 
[ERROR] Please refer to /var/lib/jenkins/jobs/Ancon-Automation/workspace/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Invoke top-level Maven targets' marked build as failure

注意:我发现了类似的问题,但找不到正确的答案。

【问题讨论】:

  • 你能把这段代码分享给chromedriver.exe路径吗?
  • 字符串文件路径 = System.getProperty("user.dir"); System.setProperty("webdriver.chrome.driver", filePath+"//src//main//java//com//ancon//automation//webDriver//chromedriver.exe"); driver = new ChromeDriver();
  • 您能否在 chrome 驱动程序路径中使用单正斜杠或双反斜杠进行检查并检查?
  • 我试过了,也改变了路径。但它仍然得到错误。有没有办法在不打开 Jenkins 中的 webdriver 的情况下运行脚本。 (跳过这一步)
  • IMO,IllegalStateException 是引发 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project Ancon: There are test failures. 的基本异常

标签: java selenium jenkins selenium-webdriver webdriver


【解决方案1】:

此错误消息...

java.lang.IllegalStateException: The driver executable does not exist: /var/lib/jenkins/jobs/Ancon-Automation/workspace\src\main\java\com\ancon\automation\webDriver\chromedriver.exe

...暗示 JVM 无法在指定位置找到 ChromeDriver 二进制文件。

您的主要问题似乎是 ChromeDriver 的有效绝对路径中 OS path.separatormixup .目前解析的有效绝对路径为:

/var/lib/jenkins/jobs/Ancon-Automation/workspace\src\main\java\com\ancon\automation\webDriver\chromedriver.exe

您需要使用 / 字符作为 path.separator,因此 ChromeDriver 的有效绝对路径变为:

  • Linux 风格(删除.exe 部分):

    /var/lib/jenkins/jobs/Ancon-Automation/workspace/src/main/java/com/ancon/automation/webDriver/chromedriver
    
  • Windows 风格(包括.exe 部分):

    /var/lib/jenkins/jobs/Ancon-Automation/workspace/src/main/java/com/ancon/automation/webDriver/chromedriver.exe
    

【讨论】:

  • 仍有问题:
  • 您确定/var/lib/..Windows OS 相关路径吗?
  • 嗨 DebanjanB,是否与此错误“无法执行目标 org.apache.maven.plugins:maven-surefire-plugin:2.20.1”有关
【解决方案2】:

请使用代码中的相对路径来设置驱动属性,如下所示

System.setProperty("webdriver.chrome.driver", "src/main/java/com/ancon/automation/webDriver/chromedriver.exe");

【讨论】:

  • 现在它显示:java.lang.IllegalStateException:驱动程序可执行文件不存在:com.ancon.automation 的 /src/main/java/com/ancon/automation/webDriver/chromedriver.exe。测试.LoginTest.SetUp(LoginTest.java:48)
  • 您的可执行文件是否放置在正确的位置?不管是在src/main/java还是src/test/java里面?
  • 是的。它位于 src/main/java 中。当我使用 Intelij-idea 运行代码时,它通过了整个测试。当我尝试使用 Jenkins 服务器运行相同的脚本时,它会显示此错误
【解决方案3】:

使用路径,您看起来像是在 linux 机器上运行测试,或者至少代码期望您在 linux 机器上执行。

因为use .exe extension on a linux box 是一个愚蠢的错误,你应该忽略它。此外,您应该只在代码中处理此类情况,因为它会在跨操作系统执行中导致令人沮丧的问题。

希望它在removing .exe part 之后有效。

【讨论】:

  • 我没有使用 Linux 机器。但我试过了:java.lang.IllegalStateException:驱动程序可执行文件不存在:/var/lib/jenkins/jobs/Ancon-Automation/workspace/src/main/java/com/ancon/automation/webDriver/chromedriver at com .ancon.automation.tests.TenantsTest.SetUp(TenantsTest.java:64)
  • 如果您可以访问 jenkins 机器,首先检查驱动程序可执行文件是否真的存在于位置:var/lib/jenkins/jobs/Ancon-Automation/workspace/src/main/java/com/ancon/自动化/webDriver。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-06-09
  • 2015-08-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多