这是错误日志,它是我的Jenkins控制台输出:
[[1;34mINFO[m]
[[1;34mINFO[m] Results:
[[1;34mINFO[m]
[[1;31mERROR[m] [1;31mFailures: [m
[[1;31mERROR[m] [1;31m mas1.test:18 » WebDriver invalid argument: can't kill an exited process
Build ...[m
[[1;34mINFO[m]
[[1;31mERROR[m] [1;31mTests run: 1, Failures: 1, Errors: 0, Skipped: 0[m
[[1;34mINFO[m]
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] [1;31mBUILD FAILURE[m
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;34mINFO[m] Total time: 19.664 s
[[1;34mINFO[m] Finished at: 2018-12-11T13:47:23+05:30
[[1;34mINFO[m] [1m------------------------------------------------------------------------[m
[[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-surefire-plugin:3.0.0-M2:test[m [1m(default-test)[m on project [36mapps[m: [1;31mThere are test failures.[m
[[1;31mERROR[m] [1;31m[m
[[1;31mERROR[m] [1;31mPlease refer to /home/ghost/IdeaProjects/apps/target/surefire-reports for the individual test results.[m
[[1;31mERROR[m] [1;31mPlease refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.[m
[[1;31mERROR[m] -> [1m[Help 1][m
[[1;31mERROR[m]
[[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
[[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
[[1;31mERROR[m]
[[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
[[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Build step 'Execute shell' marked build as failure
Finished: FAILURE
在/ home / ghost / IdeaProjects / apps中
我尝试使用此代码
mvn clean test
成功构建并打开浏览器 然后关闭
但是当我遍历詹金斯时,这只是一个问题
在Jenkins构建中,我选择execute shell并输入此命令
cd /home/ghost/IdeaProjects/apps
mvn clean test
如何解决此错误
詹金斯詹金斯版。 2.150.1
java -version:openjdk版本“ 1.8.0_191”
答案 0 :(得分:3)
如果您正在使用Jenkins集成并且您的本地运行正常。您的问题很可能是无头问题。另一件事是浏览器未正确打开。
我遇到了这种情况,我的解决方案是使用无头浏览器并根据两种平台正确配置它。如果您的jenkins服务器在不同的平台上运行,例如:-Windows为本地Jenkins在Linux中。那么您必须在两个平台上对其进行测试。只需在运行之前和运行期间捕获图像,即可在詹金斯中检查其运行是否正确。
这是与Linux和Windows匹配的脚本
}else if(browser.equalsIgnoreCase("HLChrome")){
//Headless chrome browser and configure
WebDriverManager.chromedriver().setup();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("disable-gpu");
// chromeOptions.addArguments("window-size=1400,2100"); // linux should be activate
driver = new ChromeDriver(chromeOptions);
如果使用的是Linux环境,则还必须添加--no-sandbox以及特定的窗口大小设置。如果正确设置用户容器,则Windows中不需要--no-sandbox。
disable-gpu仅在Windows上。其他平台不再需要它。 --disable-gpu标志是一些错误的临时解决方法。