简体   繁体   English

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

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

I have selenium testing Maven project and i create a job on jenkins to run the POM.xml file by integrating it with GitHub. 我已经对Maven项目进行了硒测试,并且在jenkins上创建了一个作业,通过将其与GitHub集成来运行POM.xml文件。 So when i click on "Build Now" to run the job in Jenkins its directly get the entire code from git and works as expected with SUCCESS result on windows machine. 因此,当我单击“立即构建”以在Jenkins中运行作业时,它直接从git中获取了整个代码,并在Windows计算机上按预期的方式与SUCCESS结果一起工作。 But when i create the same job in Jenkins on Linux machine it gives me errors. 但是,当我在Linux计算机上的Jenkins中创建相同的作业时,它给了我错误。 Need help on this 在这方面需要帮助

    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

Given you're running your test on a Linux box you need to use Linux chromedriver version 假设您要在Linux机器上运行测试,则需要使用Linux chromedriver版本

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

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

Make sure to make it executable by running chmod command like: 确保通过运行chmod命令使其可执行,例如:

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

However it should be easier to integrate WebDriverManager to automatically download the necessary version of the driver for your browser. 但是,集成WebDriverManager以便为浏览器自动下载所需版本的驱动程序应该更容易。

If your Linux machine doesn't have GUI you will also either need to setup Xvfb or add --headless key to your browser initialization routine. 如果您的Linux机器没有GUI,则还需要设置Xvfb或在浏览器初始化例程中添加--headless键。

More information: How to use Jenkins pipeline to launch Selenium tests 详细信息: 如何使用Jenkins管道启动Selenium测试

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

相关问题 Netbeans Maven项目在Windows中运行,但不在Linux中运行 - Netbeans Maven project runs in windows, but not in Linux Maven和Jenkins:构建项目时出现依赖错误 - Maven and Jenkins: dependancy error when builidng project PHP项目可在Linux服务器上运行,但不能在Windows上运行 - php project works on linux server but not on windows eclipse Charset在同一个Project上使用Windows和Linux - eclipse Charset for working with Windows & Linux on same Project 输入相同,Z3在Windows上工作,但在Linux上出现分段错误 - Same input, Z3 works on Windows, but gives Segmentation Faults on Linux Jenkins在Linux或Windows上运行Maven构建 - Jenkins to run Maven build on Linux or Windows 适用于Linux和Windows的单个InstallJammer项目? - Single InstallJammer Project for Linux and Windows? 使用Linux命令行运行Java Maven项目 - Run Java Maven project with Linux command line 我的python程序在Windows 7中可以正常工作并打印到控制台,但在Linux Mint中却报错? - My python program works fine in Windows 7 and prints to the console but gives an error in Linux Mint? Gradle robolectric项目适用于OSX计算机,但不适用于Linux - Gradle robolectric project works on OSX computer but not on Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM