有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

selenium java。lang.IllegalStateException:驱动程序可执行文件不存在:/var/lib/jenkins/jobs/AnconAutomation/workspace\src\main\。。。\镀铬器。exe

单击“构建”时,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

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


共 (3) 个答案

  1. # 1 楼答案

    使用path,看起来您正在linux机器上运行测试,或者至少代码希望您在linux机器上执行

    既然{}是一个愚蠢的错误,你应该忽略它。此外,您还应该在代码中处理此类情况,因为它会在跨操作系统执行中导致令人沮丧的问题

    希望它在removing .exe part之后能起作用

  2. # 2 楼答案

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

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

    此错误消息

    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二进制文件

    您的主要问题似乎与操作系统的路径相混淆。分离器色度驱动器的有效绝对路径内。目前已解析的有效绝对路径为:

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

    您需要使用/字符作为路径。分隔符,因此色度驱动器的有效绝对路径变为:

    • 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