【发布时间】:2017-10-08 17:07:12
【问题描述】:
我正在尝试使用 jenkins 运行 selenium 测试用例。我正在为我的测试用例使用 maven 和 TestNG。测试用例在本地机器上运行良好,而我试图在服务器上使用 jenkins 运行测试用例以下错误。
+ mvn test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DataVisualisation 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ DataVisualisation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/sample-selenium-datum/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ DataVisualisation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ DataVisualisation ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/sample-selenium-datum/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ DataVisualisation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) @ DataVisualisation ---
[INFO] Surefire report directory: /home/sample-selenium-datum/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Configuring TestNG with: TestNG652Configurator
Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 18007
Only local connections are allowed.
May 10, 2017 7:11:11 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
May 10, 2017 7:11:11 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Configuring TestNG with: TestNG652Configurator
Tests run: 5, Failures: 1, Errors: 0, Skipped: 3, Time elapsed: 2.464 sec <<< FAILURE! - in TestSuite
invokeBrowser(datum.LoginTest) Time elapsed: 2.063 sec <<< FAILURE!
org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.4.0-71-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 40 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'devopspipe', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-71-generic', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: cannot find Chrome binary
(Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.4.0-71-generic x86_64), platform=ANY}]
Session ID: 32a6fb3761613a68f59bc37a5e0d0491
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:658)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:882)
at datum.UtilsMethods.browserInvoke(UtilsMethods.java:77)
at datum.LoginTest.invokeBrowser(LoginTest.java:19)
Results :
Failed tests:
LoginTest.invokeBrowser:19 » NoSuchSession no such session
(Driver info: chr...
Tests run: 5, Failures: 1, Errors: 0, Skipped: 3
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.874 s
[INFO] Finished at: 2017-05-10T07:11:12+00:00
[INFO] Final Memory: 10M/28M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.17:test (default-test) on project DataVisualisation: There are test failures.
[ERROR]
[ERROR] Please refer to /home/sample-selenium-datum/target/surefire-reports for the individual test results.
[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 'Execute shell' marked build as failure
Finished: FAILURE
【问题讨论】:
-
您需要解决以下一些关键问题: 1.
Configuring TestNG with: TestNG652Configurator- 向我们展示 TestNG652Configurator 代码。 2.FAILURE! - in TestSuite- 向我们展示 testng.xml 3.NoSuchSessionException: no such session- 向我们展示浏览器启动代码。 4.Driver info: chromedriver=2.27- 提高到 chromedriver=2.29 5. 在通过 Jenkins 执行代码之前,尝试将 TestNG 代码作为 TestNG 测试执行,然后作为 TestNG 套件作为 Maven 测试执行。
标签: jenkins selenium-webdriver