尝试在Jenkins上运行Selenium时出现NoSuchSession异常

时间:2017-09-27 19:05:32

标签: java linux maven selenium jenkins

OS:
Linux的 Selenium版本:
3.1.0 浏览器:
谷歌浏览器

尝试在Jenkins上运行selenium代码会产生这个问题:

Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 21812
Only local connections are allowed.
Sep 27, 2017 2:31:27 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 29075
Only local connections are allowed.
Sep 27, 2017 2:32:28 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 6967
Only local connections are allowed.
Sep 27, 2017 2:33:28 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Starting ChromeDriver 2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57) on port 31312
Only local connections are allowed.
Sep 27, 2017 2:34:28 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
[ERROR] Tests run: 26, Failures: 4, Errors: 0, Skipped: 22, Time elapsed: 242.653 s <<< FAILURE! - in TestSuite
[ERROR] setUp(BrkProducts.LoginTest)  Time elapsed: 62.029 s  <<< FAILURE!
org.openqa.selenium.NoSuchSessionException: 
no such session
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-327.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 14 milliseconds
Build info: version: '3.1.0', revision: 'b94c902', time: '2017-02-16 12:21:31 -0800'
System info: host: 'xyz.com', ip: '10.4.124.176', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.el7.x86_64', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.30.477691 (6ee44a7247c639c0703f291d320bdf05c1531b57),platform=Linux 3.10.0-327.el7.x86_64 x86_64), platform=ANY}]
Session ID: 0e4c67c28f18b452df9f0d3916aba043
    at BrkProducts.LoginTest.setUp(LoginTest.java:19)

然后,它跳过该类中的所有以下测试。其后是:

[INFO] 
[INFO] Results:
[INFO] 
[ERROR] Failures: 
[ERROR] BrkProducts.ButtonTest.setUp(BrkProducts.ButtonTest)
[ERROR]   Run 1: ButtonTest.setUp:23->Methods.setup:135 » NoSuchSession no such session
  (Driv...
[INFO]   Run 2: PASS
[INFO] 

过程变得不稳定:

Please refer to /var/lib/jenkins/workspace/SmokeTest/target/surefire-reports for the individual test results.
Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[JENKINS] Recording test results
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:14 min
[INFO] Finished at: 2017-09-27T14:34:32-04:00
[INFO] Final Memory: 29M/276M
[INFO] ------------------------------------------------------------------------
[JENKINS] Archiving /var/lib/jenkins/workspace/SmokeTest/pom.xml to com.enso.automation/TestingAutomation/1.0-SNAPSHOT/TestingAutomation-1.0-SNAPSHOT.pom
channel stopped
Finished: UNSTABLE

经过所有的研究,感觉这个网站实际上并没有在这里加载。不知道Jenkins发生了什么。

非常感谢任何帮助。感谢

1 个答案:

答案 0 :(得分:0)

Linux服务器中的Chrome版本是什么?从您的评论我明白它适用于您的Windows机器。您可以安装与Windows中相同版本的Chrome。无论如何,在此链接https://sites.google.com/a/chromium.org/chromedriver/downloads中有一些关于兼容性的信息。 如果你有最新版本的Chrome,你可以尝试使用最新版本的ChromeDriver(现在是2.32)而不是2.30