我使用Selenium WebDriver编写了一个自动化测试脚本,它将打开一个浏览器并导航到一个站点,然后关闭浏览器。
这是一个Maven项目,因为我使用Eclipse,所以我可以用' Run As'来执行项目。 - > ' Maven Test'并且项目将在控制台中执行并且Build is Success。
但是当我尝试通过Jenkins执行同一个项目时,Jenkins无法启动chromedriver。
以下是控制台输出:
Started by user QA Admin
Building in workspace /var/lib/jenkins/workspace/WebDriverTest2
Parsing POMs
Modules changed, recalculating dependency graph
Established TCP socket on 42178
[WebdriverTest] $ java -Xms1024m -Xmx4096m -XX:PermSize=1024m -cp /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-agent-1.7.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/boot/plexus-classworlds-2.5.2.jar:/var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven/conf/logging jenkins.maven3.agent.Maven32Main /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/Maven /var/cache/jenkins/war/WEB-INF/lib/remoting-2.60.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven32-interceptor-1.7.jar /var/lib/jenkins/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-commons-1.7.jar 42178
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=1024m; support was removed in 8.0
<===[JENKINS REMOTING CAPACITY]===>channel started
Executing Maven: -B -f /home/admin/workspace/WebdriverTest/pom.xml test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building WebdriverTest 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ WebdriverTest ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ WebdriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ WebdriverTest ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ WebdriverTest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.19.1:test (default-test) @ WebdriverTest ---
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Starting ChromeDriver 2.23.409687 (c46e862757edc04c06b1bd88724d15a5807b84d1) on port 13012
Only local connections are allowed.
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2, Time elapsed: 61.125 sec <<< FAILURE! - in TestSuite
beforeTest(example.NewTest) Time elapsed: 61.027 sec <<< FAILURE!
org.openqa.selenium.WebDriverException:
unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.23.409687 (c46e862757edc04c06b1bd88724d15a5807b84d1),platform=Linux 3.16.0-77-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.22 seconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'AZDTPDE-L2', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.16.0-77-generic', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
at example.NewTest.beforeTest(NewTest.java:31)
Results :
Failed tests:
NewTest.beforeTest:31 » WebDriver unknown error: Chrome failed to start: exite...
Tests run: 3, Failures: 1, Errors: 0, Skipped: 2
[ERROR] There are test failures.
Please refer to /home/admin/workspace/WebdriverTest/target/surefire-reports for the individual test results.
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:07 min
[INFO] Finished at: 2016-08-26T12:09:35+05:30
[INFO] Final Memory: 28M/1059M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /home/admin/workspace/WebdriverTest/pom.xml to WebdriverTest/WebdriverTest/0.0.1-SNAPSHOT/WebdriverTest-0.0.1-SNAPSHOT.pom
/home/admin/workspace/WebdriverTest/pom.xml is not inside /var/lib/jenkins/workspace/WebDriverTest2/home/admin/workspace/WebdriverTest/; will archive in a separate pass
channel stopped
Finished: UNSTABLE
我正在使用Ubuntu 14.04操作系统。
非常感谢任何帮助。提前致谢。请帮忙。有什么帮助吗?