Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session ID is null #1418

Closed
monolithed opened this issue Jun 29, 2016 · 11 comments
Closed

Session ID is null #1418

monolithed opened this issue Jun 29, 2016 · 11 comments

Comments

@monolithed
Copy link

monolithed commented Jun 29, 2016

17:34:43.129 INFO - Executing: [new session: Capabilities [{rotatable=true, acceptSslCerts=true, locationContextEnabled=true, processNumber=1, logging
Prefs=org.openqa.selenium.logging.LoggingPreferences@68cebdc5, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=we
bdriverio, version=4.1.1, url=http://webdriver.io}}]])
17:34:43.153 INFO - Creating a new session for Capabilities [{rotatable=true, acceptSslCerts=true, locationContextEnabled=true, processNumber=1, loggi
ngPrefs=org.openqa.selenium.logging.LoggingPreferences@68cebdc5, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=
webdriverio, version=4.1.1, url=http://webdriver.io}}]
Starting ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) on port 13850
Only local connections are allowed.
17:34:48.138 INFO - Done: [new session: Capabilities [{rotatable=true, acceptSslCerts=true, locationContextEnabled=true, processNumber=1, loggingPrefs
=org.openqa.selenium.logging.LoggingPreferences@68cebdc5, browserName=chrome, javascriptEnabled=true, handlesAlerts=true, requestOrigins={name=webdriv
erio, version=4.1.1, url=http://webdriver.io}}]]
17:34:48.950 INFO - Executing: [get: https://mail-50708.omega.test.mail.ru/login])
17:34:55.955 INFO - Done: [get: https://mail-50708.omega.test.mail.ru/login]
17:34:56.042 INFO - Executing: [add cookie: Mpop=1467210889:4c0e0b715406565c190502190805001b0b071d0a0c4568515c455f06040a1e0a730e1e545c545f595a58431954
425c584d10525d164047:melnikov.ashot@bk.ru:; path=/; domain=.mail.ru])
17:34:56.098 INFO - Done: [add cookie: Mpop=1467210889:****
84d10525d164047:****@bk.ru:; path=/; domain=.mail.ru]
17:34:56.122 INFO - Executing: [add cookie: t=obLD1AAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAACAABEJsQcA; path=/; domain
=.mail.ru])
17:34:56.216 INFO - Done: [add cookie: t=obLD1AAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAACAABEJsQcA; path=/; domain=.mai
l.ru]
17:34:56.258 INFO - Executing: [add cookie: sdcs=****; path=/; domain=.mail.ru])
17:34:56.293 INFO - Done: [add cookie: sdcs=****; path=/; domain=.mail.ru]
17:34:56.322 INFO - Executing: [execute script: return (function () {
                        return window.patron.username;
                }).apply(null, arguments), []])
17:34:56.401 INFO - Done: [execute script: return (function () {
                        return window.patron.username;
                }).apply(null, arguments), []]
17:34:56.434 INFO - Executing: [get: https://*****.mail.ru/messages/inbox?])
17:34:58.962 INFO - Executing: [delete session: 2d6a19bc-7d26-4abe-9ebb-7dadd04575d9])
17:35:03.416 INFO - Done: [get: https://*****.mail.ru/messages/inbox?]
17:35:03.468 INFO - Executing: [find elements: By.id: b-letters])
17:35:04.884 INFO - Done: [delete session: 2d6a19bc-7d26-4abe-9ebb-7dadd04575d9]
17:35:06.067 WARN - Exception thrown
org.openqa.selenium.remote.SessionNotFoundException: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'M1USER1903', ip: '100.120.16.149', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: driver.version: EventFiringWebDriver
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:134)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
        at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:388)
        at org.openqa.selenium.remote.RemoteWebDriver.findElementsById(RemoteWebDriver.java:421)
        at org.openqa.selenium.By$ById.findElements(By.java:210)
        at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:351)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver$2.invoke(EventFiringWebDriver.java:103)
        at com.sun.proxy.$Proxy1.findElements(Unknown Source)
        at org.openqa.selenium.support.events.EventFiringWebDriver.findElements(EventFiringWebDriver.java:177)
        at org.openqa.selenium.remote.server.handler.FindElements.call(FindElements.java:50)
        at org.openqa.selenium.remote.server.handler.FindElements.call(FindElements.java:1)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
17:35:06.079 WARN - Exception: Session ID is null. Using WebDriver after calling quit()?
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'M1USER1903', ip: '100.120.16.149', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_92'
Driver info: driver.version: EventFiringWebDriver

Sometimes I see this error in chrome (phantomjs works fine).

I have found a possible solution: http://stackoverflow.com/questions/27497875/selenium-grid-running-tests-in-parallel

Do not set driver in the base class, do not have driver property at all. The same instance is being overridden by different threadlocal drivers.
Any time you want to run your test, refer to WebDriverSetup.getDriver() in your test method itself and in your after/before methods.

PS: My tests are starting via Launcher, if it can help

@christian-bromann
Copy link
Member

If you delete the session we set the sessionID to null. As you can see in the logs you execute: 17:35:03.468 INFO - Executing: [find elements: By.id: b-letters]) after the test is done. Looks like a race condition in your test.

@monolithed
Copy link
Author

monolithed commented Jun 29, 2016

17:34:56.258 INFO - Executing: [add cookie: sdcs=****; path=/; domain=.mail.ru])
17:34:56.293 INFO - Done: [add cookie: sdcs=****; path=/; domain=.mail.ru]
17:34:56.322 INFO - Executing: [execute script: return (function () {
                        return window.patron.username;
                }).apply(null, arguments), []])
17:34:56.401 INFO - Done: [execute script: return (function () {
                        return window.patron.username;
                }).apply(null, arguments), []]
17:34:56.434 INFO - Executing: [get: https://*****.mail.ru/messages/inbox?])
17:34:58.962 INFO - Executing: [delete session: 2d6a19bc-7d26-4abe-9ebb-7dadd04575d9])
17:35:03.416 INFO - Done: [get: https://*****.mail.ru/messages/inbox?]
17:35:03.468 INFO - Executing: [find elements: By.id: b-letters])
17:35:04.884 INFO - Done: [delete session: 2d6a19bc-7d26-4abe-9ebb-7dadd04575d9]
17:35:06.067 WARN - Exception thrown

➜ setCookie
➜ execute script
delete session
➜ find elements
delete session
➜ exception thrown

After excluding ➜ execute script:

➜ setCookie
delete session
➜ find elements
delete session
➜ exception thrown

Executing: [find elements: By.id: b-letters])

There's no any warnings and #b-letters exists
How to keep the session?

@monolithed
Copy link
Author

monolithed commented Jun 29, 2016

I can replicate it only with Chrome browser. And have no idea who may throw that exception

@christian-bromann
Copy link
Member

Who is deleting session?

the wdio test runner because

@monolithed
Copy link
Author

monolithed commented Jun 30, 2016

the wdio test runner because

So, how to know the reason? I could not find any information in the logs

@christian-bromann
Copy link
Member

If the spec has finished the wdio runner automatically shuts down the session

@monolithed
Copy link
Author

monolithed commented Jun 30, 2016

My test case (nothing else):

browser.url(url);
browser.setCookie(cookie);
browser.url(url); 
browser.waitForExist(selector);

Cannot understand how it's possible within one test case

@christian-bromann
Copy link
Member

I can't not tell you anything more without having a reproducible example or something I can investigate on.

@monolithed
Copy link
Author

I can reproduce it on Windows with Cygwin in Chrome.
PS: Works fine on Mac.

@samantha-pereira
Copy link

samantha-pereira commented Nov 5, 2019

I'm having the same error as session ID is null. I have created a selenium grid with firefox and chrome. Below is my code:

Yaml file

version: "3"
services:
selenium-hub:
image: selenium/hub:latest
container_name: selenium-hub
ports:
- "4444:4444"
chrome:
image: selenium/node-chrome-debug:latest
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
firefox:
image: selenium/node-firefox:latest
volumes:
- /dev/shm:/dev/shm
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444

Test case file

package docker

import java.net.{MalformedURLException, URL}

import org.openqa.selenium.remote.{DesiredCapabilities, RemoteWebDriver}
import org.openqa.selenium.{OutputType, TakesScreenshot, WebDriver}
import org.scalatest.{BeforeAndAfter, FlatSpecLike, Matchers}
import org.testng.annotations._
import org.testng.annotations.Test

class SignUpTests_Chrome_2 extends FlatSpecLike with Matchers {

var driver: WebDriver = null

@BeforeTest @throws[MalformedURLException]
def doBeforeTest{
val cap = DesiredCapabilities.chrome
val url = new URL("http://localhost:4444/wd/hub")
driver = new RemoteWebDriver(url, cap)
driver.manage().window().maximize()
}

@AfterTest
def doAfterTest{
driver.quit()
}

@test
def goto_staging (){
driver.get("https://www.amazon.com/");
System.out.println("Title of Amazon Home page: "+driver.getTitle() + "\n")

}

}

Error:

org.openqa.selenium.WebDriverException: Session [(null externalkey)] not available and is not among the last 1000 terminated sessions. Active sessions are[ext. key f7bc1bfc4ff2fb1a1cae697f63533e9e] Command duration or timeout: 21 milliseconds Build info: version: '2.35.0', revision: '8df0c6bedf70ff9f22c647788f9fe9c8d22210e2', time: '2013-08-17 12:46:41' System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14', java.version: '11.0.2' Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities [{capabilities={networkConnectionEnabled=false, chrome={chromedriverVersion=78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}), userDataDir=/tmp/.com.google.Chrome.ZPNYml}, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, unhandledPromptBehavior=dismiss and notify, strictFileInteractability=false, proxy={}, goog:chromeOptions={debuggerAddress=localhost:41859}, webdriver.remote.sessionid=f7bc1bfc4ff2fb1a1cae697f63533e9e, acceptInsecureCerts=false, browserVersion=78.0.3904.70, browserName=chrome, platformName=linux, setWindowRect=true}, sessionId=f7bc1bfc4ff2fb1a1cae697f63533e9e, platform=ANY}] Session ID: null

@mgrybyk
Copy link
Member

mgrybyk commented Nov 5, 2019

@samantha-pereira the issue opened 3 years ago, and this is javascript project, c'mon man, are you serious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants