-1

I am running selenium grid and has 2 nodes connected to it. But when I try to run a test script (.java) it gives the error:

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'

In the VNC client the chrome browser opens up but the url is not getting loaded and the error is thrown.

Note: The script is run from another docker container using maven.

When I run the script as a java application, it works fine, but in docker, I'm getting the error.**

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

This error message...

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'

...implies that the Selenium Grid Node was unable to communicate with the Selenium Grid Hub.


Deep Dive

This error is defined in ActiveTestSessions.java and is defined as:

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;
}

As per the following discussions:

It seems this error stems out when:

  • Selenium Grid Hub, Selenium Grid Node and the Client Process are initiated/spawned from different versions of Selenium client.

Solution

Ensure that Selenium Grid Hub, Selenium Grid Node and the Client Process all of them uses the same version of Selenium client i.e. Selenium v3.141.59


Update 1

In normal circumstances you should have observed Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError incase of presence of multiple versions of the same jar. A bit more details interms of your Test Architecture would have helped us to debug the issue in a better way. Possibly you need to clean up as follows:

  • mvn clean
  • mvn install
  • or mvn clean install
  • mvn test

Update 2

As the last resort you can delete the MAVEN_HOME i.e. ~/.m2 and re-initiate the build process.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • But then how is the script running when I am running it as an independent java application. I'm not sure about this. I had already set both the gird and node version to 3.141.59-zinc. – Midhun K G Jan 31 '20 at 09:57
  • @MidhunKG Checkout the updated answer and let me know if any question. – undetected Selenium Jan 31 '20 at 10:16
  • I thought it was the version problem and updated my pom.xml selenium dependency to 3.141.59 but still the same error. I tried running with maven clean install – Midhun K G Jan 31 '20 at 11:17
  • @MidhunKG Checkout the updated answer and let me know the status. – undetected Selenium Jan 31 '20 at 11:37
  • Still Not working. In my pom file where I specify the version for selenium a warning is shown "Overriding managed version 2.53.1 for selenium-java". Does this have anything to do with it not working. – Midhun K G Feb 04 '20 at 12:24