Katalon/Docker: org.openqa.selenium.NoSuchSessionException: invalid session id

Hi,
I am using Katalon with docker. To summarize my problem, the test suite runs correctly from the local machine. But when I run it from Katalon/Docker, I got the following error for some test case.

Error Log
Caused by: org.openqa.selenium.NoSuchSessionException: invalid session id
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: '930d9c715559', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.72-microsoft-standard-WSL2', java.version: '1.8.0_292'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 92.0.4515.159, chrome: {chromedriverVersion: 92.0.4515.43 (8c61b7e2989f2..., userDataDir: /tmp/.com.google.Chrome.RsPWFk}, goog:chromeOptions: {debuggerAddress: localhost:33311}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: b775e0c5ec3f2dd1bbbca28ca6a29f41
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
	at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:19)
	at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:489)
	at org.openqa.selenium.support.events.EventFiringWebDriver.lambda$new$1(EventFiringWebDriver.java:105)
	at com.sun.proxy.$Proxy20.executeScript(Unknown Source)
	at org.openqa.selenium.support.events.EventFiringWebDriver.executeScript(EventFiringWebDriver.java:229)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.executeJsScript(Browser.java:668)
	at com.assertthat.selenium_shutterbug.utils.web.Browser.<init>(Browser.java:83)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:139)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:83)
	at com.assertthat.selenium_shutterbug.core.Shutterbug.shootPage(Shutterbug.java:69)
	at com.kms.katalon.core.webui.util.FileUtil.takeFullPageScreenshot(FileUtil.java:86)
	at com.kms.katalon.core.webui.keyword.builtin.TakeFullPageScreenshotKeyword$_takeScreenshot_closure1.doCall(TakeFullPageScreenshotKeyword.groovy:126)
	at com.kms.katalon.core.webui.keyword.builtin.TakeFullPageScreenshotKeyword$_takeScreenshot_closure1.call(TakeFullPageScreenshotKeyword.groovy)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
	... 21 more

I found the same error already reported in that post
The post has been marked as solved (“confirmation that is an error”) but didn’t see any solution or work around the problem. Will we have a fix in the next release or something like that?

In the meantime how we can work around that issue? Anyone has an idea?
Thanks for your help

1 Like

I am having the exact same issue with the Katalon with Docker. Any solutions yet?

Hi @javier.gomez,
No solution yet, only a workaround. In my case the problem come when we try to do a full page screenshot to save a long Json content. We don’t do the screenshot anymore, we just save the Json content in a simple text file.
Hope it can help :slight_smile:

1 Like

Looks like this issue is back. I’m seeing the Caused by: org.openqa.selenium.NoSuchSessionException: invalid session id when Katalon is running in Docker. It was failing for the reason that it could take a screenshot because it was unable to click the continue button. I turned off taking a screen shot on failure. The test fails with the same reason of a session id because “2023-06-19 21:55:55.556 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] Failed to find element with id ‘Object Repository/Page_IMGING/New Job Creation/NewJobCreation_button_Continue’. Try using Self-healing.
2023-06-19 21:55:55.652 WARN c.k.k.c.webui.common.WebUiCommonHelper - [SELF-HEALING] invalid session id”

Seems like to me that the DOM for the page in docker isn’t loaded by the time the test gets to this step. Other prior steps pass and this is the first step that fails when running in Docker. Any thoughts?

1 Like

Hi Mike, i was struggling with the same issue. What helped me is to set desired capabilities like this:

Also i set this flag in the execution settings:

image

Hope this help.

@branislav.blizik Thank you for the reply. The project had the chrome args already added (not Headless) Also I only use Terminate drivers after each Test Suite. What I found was that the ChromeBrowser version and ChromeDriver version were out of sync.

Had to do a couple things:

1. Used chat.openai.com -

2. Check WebDriver Compatibility:

Ensure that you are using a compatible version of the WebDriver with the Docker environment. Sometimes, using an outdated or incompatible WebDriver version can cause issues. Make sure you have the correct WebDriver version for the browser you are testing.

3. Pinned the ChromeDriver (first) with

Pinned version of Driver
run curl https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/116.0.5845.96/linux64/chromedriver-linux64.zip -o “chromedriver_linux64.zip”
run unzip chromedriver_linux64.zip
run mv -f /chromedriver-linux64/chromedriver /opt/katalonstudio/configuration/resources/drivers/chromedriver_linux64/chromedriver
ENV PATH=“/opt/katalonstudio/configuration/resources/drivers/chromedriver_linux64:${PATH}”
run rm -r chromedriver_linux64.zip chromedriver-linux64

4. Also pinned the ChromeDriver with:

Getting the latest chrome browser
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - &&
echo “deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main” > /etc/apt/sources.list.d/google-chrome.list &&
apt-get update &&
apt-get install -y google-chrome-stable

Conclusion: This helped keep ChromeBrowser version and ChromeDriver version in sync longer during the life of the support browser version to supporting driver version. To eliminate the NoSuchSessionException:invalid session id!

You should have a look at “Chrome for Testing”

With it, you can stop the auto-updates of Chrome browser.

See the following doc how to configure your project to use Chrome for Testing and appropriate version of ChromeDriver

https://docs.katalon.com/docs/create-tests/troubleshooting-for-test-creation/troubleshoot-web-automated-testing/use-different-browser-versions