繁体   English   中英

Selenium Maven项目与jenkins集成在Windows上工作,但同一项目在Linux上出现错误

[英]Selenium Maven project integrate with jenkins works on windows but same project gives error on linux

我已经对Maven项目进行了硒测试,并且在jenkins上创建了一个作业,通过将其与GitHub集成来运行POM.xml文件。 因此,当我单击“立即构建”以在Jenkins中运行作业时,它直接从git中获取了整个代码,并在Windows计算机上按预期的方式与SUCCESS结果一起工作。 但是,当我在Linux计算机上的Jenkins中创建相同的作业时,它给了我错误。 在这方面需要帮助

    Started by user Admin fmcdjen
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/SeleniumTest
[Pipeline] {
[Pipeline] timeout
Timeout set to expire in 20 min
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Checkout SCM)
[Pipeline] echo
Checking out git repo
[Pipeline] checkout
using credential gitHubID
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url git@github.ford.com:dealer-platform/QA-selenium-automation.git # timeout=10
Fetching upstream changes from git@github.ford.com:dealer-platform/QA-selenium-automation.git
 > git --version # timeout=10
using GIT_SSH to set credentials 
 > git fetch --tags --progress git@github.ford.com:dealer-platform/QA-selenium-automation.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse origin/master^{commit} # timeout=10
Checking out Revision 25693e55034bef998abb437292745132f8b9c1c4 (origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 25693e55034bef998abb437292745132f8b9c1c4
Commit message: "comitted"
 > git rev-list --no-walk 25693e55034bef998abb437292745132f8b9c1c4 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Maven Build & Unit Testing)
[Pipeline] echo
Maven build and test
[Pipeline] withMaven
[withMaven] Options: []
[withMaven] Available options: 
[withMaven] using JDK installation provided by the build agent
[withMaven] using Maven installation 'Maven_3.6.0'
[Pipeline] {
[Pipeline] sh
+ mvn test -DSuiteXmlFile=testng.xml
----- withMaven Wrapper script -----
Picked up JAVA_TOOL_OPTIONS: -Dmaven.ext.class.path="/var/jenkins_home/workspace/SeleniumTest@tmp/withMavena8cb286b/pipeline-maven-spy.jar" -Dorg.jenkinsci.plugins.pipeline.maven.reportsFolder="/var/jenkins_home/workspace/SeleniumTest@tmp/withMavena8cb286b" 
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T14:41:47-04:00)
Maven home: /var/jenkins_home/tools/hudson.tasks.Maven_MavenInstallation/Maven_3.6.0
Java version: 1.8.0_181, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-957.21.2.el7.x86_64", arch: "amd64", family: "unix"
[INFO] [jenkins-event-spy] Generate /var/jenkins_home/workspace/SeleniumTest@tmp/withMavena8cb286b/maven-spy-20190719-093036-9118622080910645891447.log.tmp ...
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for FMCDealerFramework:FMCDealerFramework:jar:0.0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for util.Xls_Reader:Xls_Reader:jar should not point at files within the project directory, ${project.basedir}/repository/xls_Reader.jar will be unresolvable by dependent projects @ line 42, column 24
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] 
[INFO] ---------------< FMCDealerFramework:FMCDealerFramework >----------------
[INFO] Building FMCDealerFramework 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ FMCDealerFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ FMCDealerFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ FMCDealerFramework ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /var/jenkins_home/workspace/SeleniumTest/src/test/resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ FMCDealerFramework ---
[INFO] No sources to compile
[INFO] 
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ FMCDealerFramework ---
[INFO] No tests to run.
[INFO] 
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
...
... TestNG 6.14.3 by Cédric Beust (cedric@beust.com)
...

pass
pass
pass
pass
Read test data file mailreport.properties...
No Recepient Email Ids found.
No Recepient Email Ids found.
No Recepient Email Ids found.
[ERROR] Tests run: 12, Failures: 8, Errors: 0, Skipped: 4, Time elapsed: 1.232 s <<< FAILURE! - in TestSuite
[ERROR] setUpBrowser(com.ford.FMCDealer.testcases.TC04_FMC_Quick_Filters)  Time elapsed: 0.362 s  <<< FAILURE!
java.lang.IllegalStateException: The driver is not executable: /var/jenkins_home/workspace/SeleniumTest/./lib/chromedriver.exe

[ERROR] tearDown(com.ford.FMCDealer.testcases.TC04_FMC_Quick_Filters)  Time elapsed: 0.443 s  <<< FAILURE!
java.lang.NullPointerException

[ERROR] setUpBrowser(com.ford.FMCDealer.testcases.TC07_FMC_Stemming)  Time elapsed: 0.446 s  <<< FAILURE!
java.lang.IllegalStateException: The driver is not executable: /var/jenkins_home/workspace/SeleniumTest/./lib/chromedriver.exe

[ERROR] tearDown(com.ford.FMCDealer.testcases.TC07_FMC_Stemming)  Time elapsed: 0.448 s  <<< FAILURE!
java.lang.NullPointerException

[ERROR] setUpBrowser(com.ford.FMCDealer.testcases.TC05_FMC_Toggle_to_change_view)  Time elapsed: 0.449 s  <<< FAILURE!
java.lang.IllegalStateException: The driver is not executable: /var/jenkins_home/workspace/SeleniumTest/./lib/chromedriver.exe

[ERROR] tearDown(com.ford.FMCDealer.testcases.TC05_FMC_Toggle_to_change_view)  Time elapsed: 0.45 s  <<< FAILURE!
java.lang.NullPointerException

[ERROR] setUpBrowser(com.ford.FMCDealer.testcases.TC03_FMC_Sort_Option_Filter)  Time elapsed: 0.453 s  <<< FAILURE!
java.lang.IllegalStateException: The driver is not executable: /var/jenkins_home/workspace/SeleniumTest/./lib/chromedriver.exe

[ERROR] tearDown(com.ford.FMCDealer.testcases.TC03_FMC_Sort_Option_Filter)  Time elapsed: 0.455 s  <<< FAILURE!
java.lang.NullPointerException

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR]   TC03_FMC_Sort_Option_Filter>TestCaseBase.setUpBrowser:104->TestCaseBase.selectBrowser:157->TestCaseBase.setUpChromeWin32:351 » IllegalState
[ERROR]   TC03_FMC_Sort_Option_Filter>TestCaseBase.tearDown:296 » NullPointer
[ERROR]   TC04_FMC_Quick_Filters>TestCaseBase.setUpBrowser:104->TestCaseBase.selectBrowser:157->TestCaseBase.setUpChromeWin32:351 » IllegalState
[ERROR]   TC04_FMC_Quick_Filters>TestCaseBase.tearDown:296 » NullPointer
[ERROR]   TC05_FMC_Toggle_to_change_view>TestCaseBase.setUpBrowser:104->TestCaseBase.selectBrowser:157->TestCaseBase.setUpChromeWin32:351 » IllegalState
[ERROR]   TC05_FMC_Toggle_to_change_view>TestCaseBase.tearDown:296 » NullPointer
[ERROR]   TC07_FMC_Stemming>TestCaseBase.setUpBrowser:104->TestCaseBase.selectBrowser:157->TestCaseBase.setUpChromeWin32:351 » IllegalState
[ERROR]   TC07_FMC_Stemming>TestCaseBase.tearDown:296 » NullPointer
[INFO] 
[ERROR] Tests run: 12, Failures: 8, Errors: 0, Skipped: 4
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  6.880 s
[INFO] Finished at: 2019-07-19T09:30:44-04:00
[INFO] ------------------------------------------------------------------------
[INFO] [jenkins-event-spy] Generated /var/jenkins_home/workspace/SeleniumTest@tmp/withMavena8cb286b/maven-spy-20190719-093036-9118622080910645891447.log
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M3:test (default-test) on project FMCDealerFramework: There are test failures.
[ERROR] 
[ERROR] Please refer to /var/jenkins_home/workspace/SeleniumTest/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].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
[Pipeline] }
[withMaven] junitPublisher - Archive test results for Maven artifact FMCDealerFramework:FMCDealerFramework:jar:0.0.1-SNAPSHOT generated by maven-surefire-plugin:test (default-test): target/surefire-reports/*.xml
[withMaven] junitPublisher - Jenkins JUnit Attachments Plugin not found, can't publish test attachments.Recording test results
[withMaven] Jenkins Task Scanner Plugin not found, don't display results of source code scanning for 'TODO' and 'FIXME' in pipeline screen.
[withMaven] Publishers: Pipeline Graph Publisher: 2 ms, Junit Publisher: 34 ms
[Pipeline] // withMaven
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // timeout
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

假设您要在Linux机器上运行测试,则需要使用Linux chromedriver版本

即适用于Chrome 75的浏览器: https//chromedriver.storage.googleapis.com/index.html?path = 75.0.3770.140 /

您应该使用https://chromedriver.storage.googleapis.com/75.0.3770.140/chromedriver_linux64.zip

确保通过运行chmod命令使其可执行,例如:

script {
    sh 'chmod +x /var/jenkins_home/workspace/SeleniumTest/./lib/chromedriver'
}

但是,集成WebDriverManager以便为浏览器自动下载所需版本的驱动程序应该更容易。

如果您的Linux机器没有GUI,则还需要设置Xvfb或在浏览器初始化例程中添加--headless键。

详细信息: 如何使用Jenkins管道启动Selenium测试

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM