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

标签 java linux maven selenium jenkins

操作系统:
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 中发生了什么。

非常感谢这里的任何帮助。谢谢

最佳答案

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

关于java - 尝试在 Jenkins 上运行 Selenium 时出现 NoSuchSession 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46455454/

相关文章:

java - XSD 中的哪个属性将在 JAXB 生成的类中使用 @XmlElement(required = false) 注释字段

java - 数字与分数相乘

linux - 访问wait_event_timeout Linux接口(interface)中的共享变量

linux 上的 java - 必须按两次 CtrlD

java - tomcat7日志不断重复同样的错误

java - 部署spring boot应用需要web.xml吗

java - HikariCP 与 JDBC 指标 Spring Boot2

linux - 当你给它一个服务的默认端口号时返回一个服务名称的脚本

java - org.springframework.beans.factory.BeanCreationException : Error creating bean with name 'jdbcTemplate' defined in class path resource

java - 下载项目依赖时Maven(SSL相关?)抛出IllegalStateException