我正在运行硒网格,并且有2个节点连接到它。但是,当我尝试运行测试脚本(.java)时,出现错误:
Exception in thread "Thread-23" org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 3e5f8fb2ae3b0c5cddc8817f80eb8fe1]
Command duration or timeout: 92 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
在VNC客户端中,Chrome浏览器打开,但是未加载URL并引发了错误。
注意:该脚本是使用maven从另一个Docker容器运行的。
当我将脚本作为Java应用程序运行时,它可以正常工作,但是在docker中,我收到了错误消息。**
此错误消息...
Exception in thread "Thread-23" org.openqa.selenium.WebDriverException: Session [null] not available and is not among the last 1000 terminated sessions.
Active sessions are[ext. key 3e5f8fb2ae3b0c5cddc8817f80eb8fe1]
Command duration or timeout: 92 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
...表示Selenium Grid Node无法与Selenium Grid Hub通信。
此错误在ActiveTestSessions.java中定义,并定义为:
public TestSession getExistingSession(ExternalSessionKey externalkey) {
TestSession sessionByExternalKey = findSessionByExternalKey(externalkey);
if (sessionByExternalKey == null) {
SessionTerminationReason sessionTerminationReason = reasons.get(externalkey);
String keyId = externalkey != null ? externalkey.getKey() : "(null externalkey)";
if (sessionTerminationReason != null) {
String msg = "Session [" + keyId + "] was terminated due to " + sessionTerminationReason;
log.fine(msg);
throw new GridException(msg);
} else {
String msg = "Session [" + keyId + "] not available and is not among the last 1000 terminated sessions.\n"
+ "Active sessions are" + this.unmodifiableSet();
log.fine(msg);
throw new GridException(msg);
}
}
return sessionByExternalKey;
}
根据以下讨论:
看来此错误源于以下时间:
确保Selenium Grid Hub,Selenium Grid Node和Client Process都使用相同版本的Selenium客户端,即Selenium v3.141.59
[在正常情况下,如果同一罐子存在多个版本,则应该观察到Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError。您的Test Architecture的更多细节将帮助我们以更好的方式调试问题。可能您需要按以下方式清理:
mvn clean
mvn install
mvn clean install
mvn test