org.openqa.selenium.WebDriverException:会话[null]不可用,也不是在Docker中使用SeleniumGrid的最近1000个终止会话中的会话

问题描述 投票:-1回答:1

我正在运行硒网格,并且有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中,我收到了错误消息。**

maven selenium docker selenium-webdriver selenium-grid
1个回答
-1
投票

此错误消息...

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 HubSelenium Grid NodeClient Process是从Selenium客户端的不同版本启动/产生的。

解决方案

确保Selenium Grid HubSelenium Grid NodeClient Process都使用相同版本的Selenium客户端,即Selenium v​​3.141.59


更新

[在正常情况下,如果同一罐子存在多个版本,则应该观察到Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError。您的Test Architecture的更多细节将帮助我们以更好的方式调试问题。可能您需要按以下方式清理

  • mvn clean
  • mvn install
  • mvn clean install
  • mvn test
© www.soinside.com 2019 - 2024. All rights reserved.