我正在尝试使用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
答案 0 :(得分:0)
从您分享的日志中可以看出selenium无法在您的计算机中找到chrome驱动程序二进制文件
所以
1 - 您是否下载了最新的chrome驱动程序二进制文件?
2 - 您是否将chrome驱动程序的系统属性设置为二进制路径
3 - 您是否在代码中明确设置了它的路径?
分享您的代码会更好