selenium: [š Bug]: "--headlessmode=new" with Chromedriver 128 in container results in SessionNotCreatedException
What happened?
Recently we upgraded our Jenkins to the latest version and most of our (Java based) Selenium tests started failing in their pipelines, SessionNotCreatedException caused by a timeout in org.openqa.selenium.remote.http.AddSeleniumUserAgent.
Upon further investigation we found that the following combination of circumstances causes consistent failure:
- Use chromium 128 / chromedriver 128
- Use the new headless mode as
--headless=new - Run from a docker container
Iāve browsed the issues here to check if itās been reported before and it looks similar to this issue, might be the same cause.
For now our workaround is to downgrade the chromium / chromedriver version our Jenkins runs with. We could also switch our tests to --headless=old but I see that as a fix of last resort. Iād much rather Selenium and new chromedriver versions work together out of the box, even in new headless mode.
How can we reproduce the issue?
See this repository for a minimal reproducing example. For instructions on how to reproduce the issue please see the readme.
Relevant log output
> Task :test
SeleniumTest > headlessNew() FAILED
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Host info: host: '83b1fb817f96', ip: '172.17.0.1'
at app//org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
at app//org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
at app//org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:163)
at app//org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114)
at app//org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:88)
at app//org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:83)
at app//org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:72)
at app//SeleniumTest.createChromeDriver(SeleniumTest.java:26)
at app//SeleniumTest.headlessNew(SeleniumTest.java:9)
Caused by:
org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.23.0', revision: '4df0a231af'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.0-18-amd64', java.version: '21.0.4'
Driver info: driver.version: ChromeDriver
at app//org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:399)
at app//org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
at app//org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:55)
at app//org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:355)
at app//org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:89)
at app//org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:75)
at app//org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:61)
at app//org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:162)
at app//org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:216)
at app//org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:174)
at app//org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:527)
... 8 more
Caused by:
java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1960)
at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2095)
at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute0(JdkHttpClient.java:382)
... 18 more
SeleniumTest > headlessOld() STANDARD_ERROR
Aug 29, 2024 12:25:03 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 128, returning the closest version; found: 127; Please update to a Selenium version that supports CDP version 128
Gradle Test Executor 1 finished executing tests.
Operating System
Alpine 3.20, Debian 12
Selenium version
4.19.1, 4.23
What are the browser(s) and version(s) where you see this issue?
Chrome 128
What are the browser driver(s) and version(s) where you see this issue?
Chromedriver 128
Are you using Selenium Grid?
No
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 29 (11 by maintainers)
Iāve made some changes and now I am on a setup that seems to work consistently so far. Iāve changed:
With those changes made the selenium tests in the demo project now work again, seemingly consistently. I suspect the issue to be with chromium and / or chromium-chromedriver but thatās all Iāve got.
In case anyone wants to take a look at what the working project looks like Iāve created a separate branch.
Itāll eventually go out of sync but Iām too tired to fix it todayEdit: Maybe not a good solution but should stay in sync now.@qaquest I can confirm that the issue exists with google chrome when using the
selenium/node-chromeimage. Iāve added a branch to my reproducer repository that consistently reproduces the issue for me.Okay I did some more testing. The issue seems to occur only with
selenium/node-chrome:4.23.0or higher. Onselenium/node-chrome:4.22.0I donāt get the issue. Iāve checked the containers and it seems that4.23.0comes with Chrome 127 and4.22.0comes with Chrome 126. Iāve first seen these issues appear with Chromium 127, on Chromium 126 and lower everything works.So itās my assumption is that Chromium made some more breaking changes in their 127 version that donāt play well with Selenium, and the issue youāre seeing is probably not because of the latest amazonlinux version itself but rather that you end up running Selenium with some 127+ version of Chrome and those versions are just cursed.
PS: If someone finds a site that publishes the changelogs for chrome / chromium version Iād be thankful. All Iāve found was a blog post that basically said āweāre making everything better but btw weāre no loger posting changelogs, too much workā. š¤¬
Hi guys,
I faced this issue and after some tests with
strace, it looks like chromium now tries to create a directory$HOME/.config/chromium/Crash Reports/whereas the previous versions didnāt (at least it didnāt make it crash).My test Dockerfile:
test.py:
Test on read-only FS:
With .config mounted:
Just mounting a tmp FS on
$HOME/.configdoes the trick. I hope it can help to move forward on this subject.Iāve finally found that one of my colleagues can run the tests and they consistently work for them as well. Iāll be digging more into that next week, hopefully Iāll be able to narrow down the exact causes of the error. Iāll let you know once I find out more