docker-selenium
docker-selenium copied to clipboard
[🐛 Bug]: Chrome docker tags 124.0 / 4.20 SessionNotCreatedException
What happened?
I use selenium as a service in gitlab-ci.yml (selenium/standalone-chrome:latest) Before the current update this morning, everything was fine. However, after tag updates to 4.20 and 124 this morning, I started getting an error on all environments
Tried updating selenium to 4.20, tried tags : selenium/standalone-chrome:124.0 selenium/standalone-chrome:latest selenium/standalone-chrome:4.20 All of these options return the Message: Failed to start a new session
When setting tag 123.0 (selenium/standalone-chrome:123.0) everything works correctly.
Command used to start Selenium Grid with Docker (or Kubernetes)
m_test:
image: $CONTAINER_TEST_IMAGE
allow_failure: true
stage: test
services:
- name: selenium/standalone-chrome:latest
alias: chrome
variables:
SE_NODE_OVERRIDE_MAX_SESSIONS: 'true'
SE_NODE_MAX_SESSIONS: '5'
Relevant log output
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
209E Host info: host: '23ef3a12361a', ip: '172.20.0.2'
210E Build info: version: '4.20.0', revision: '866c76ca80'
211E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
212E Driver info: driver.version: unknown
213E Stacktrace:
214E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:220)
215E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:70)
216E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
217E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:464)
218E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:651)
219E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:570)
220E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:830)
221E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:790)
222E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
223E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
224E at java.lang.Thread.run (None:-1)
225/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
226
Operating System
Linux
Docker Selenium version (image tag)
latest
Selenium Grid chart version (chart version)
No response
@kisuro, thank you for creating this issue. We will troubleshoot it as soon as we can.
Info for maintainers
Triage this issue by using labels.
If information is missing, add a helpful comment and then I-issue-template label.
If the issue is a question, add the I-question label.
If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable G-* label, and it will provide the correct link and auto-close the
issue.
After troubleshooting the issue, please add the R-awaiting answer label.
Thank you!
Can you provide the test to reproduce and what binding version is used? Since our CI tests not seen this failure
Can you provide the test to reproduce and what binding version is used? Since our CI tests not seen this failure
docker:20.10.12-dind
I use pytest for tests, with fixtures, objects, etc, but the problem is that all 100 tests crashed with this error without even starting, the browser was not initialised. Even the simplest test to open any page causes this problem.
Also tried a local run with selenium 4.20 on Chrome 124.0 - all runs successfully.
I guess there is lib using HTTP/1.1 and it isn't compatible to be proceeded by selenium as the message java.io.IOException: HTTP/1.1 header parser received no bytes
@diemol, this case is Python binding. Do you have any idea how to troubleshoot?
example simple test:
import pytest
from framework.application import Application
@pytest.mark.selenium
def test_selenium(app: Application):
app.wd.get('https://www.google.com')
error log (selenium/standalone-chrome:latest):
ERROR test/mobile/test_selenium.py::test_selenium - selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
Host info: host: '5e6c8b61ce37', ip: '172.20.0.2'
Build info: version: '4.20.0', revision: '866c76ca80'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
Driver info: driver.version: unknown
Stacktrace:
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:220)
at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:70)
at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:464)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:651)
at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:570)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:830)
at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:790)
at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
at java.lang.Thread.run (None:-1)
successful log (just updated tag: selenium/standalone-chrome:123.0):
platform linux -- Python 3.10.2, pytest-8.1.1, pluggy-1.5.0 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: n
configfile: pytest.ini
plugins: xdist-3.5.0, rerunfailures-14.0, jira-xray-0.8.11, jira-0.3.20, dependency-0.6.0, allure-pytest-2.13.5, bdd-5.0.0
collecting ... collected 156 items / 1[55] deselected / 1 selected
test/mobile/test_selenium.py::test_selenium
-------------------------------- live log setup --------------------------------
2024-04-25 10:51:11 [ INFO] REMOTE MODE: FLAG DEVICE EMULATION:False (application.py:85)
2024-04-25 10:51:11 [ INFO] BROWSER:chrome VER:123.0.6312.86 (application.py:90)
2024-04-25 10:51:11 [ INFO] Browser TimeZone set to: Europe/Berlin (application.py:92)
PASSED [100%]
What version of Selenium Python?
What version of Selenium Python?
now updated to 4.20.0, was 4.19.0 . For both same result for tag 'latest' - error
@kisuro, can you try to start the container with set SE_LOG_LEVEL=FINE to see more details for reason Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
Also, at client binding, in the method app.wd.get(), is there any capabilities set related to the browser version or driver path there?
@kisuro, can you try to start the container with set
SE_LOG_LEVEL=FINEto see more details for reasonError while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytesAlso, at client binding, in the methodapp.wd.get(), is there any capabilities set related to the browser version or driver path there?
pre:
- added to gitlab-ci.yml log level variable (hope its correct, because I doesnt see any new details in log)
marked_test:
image: $CONTAINER_TEST_IMAGE
allow_failure: true
stage: test
services:
- name: selenium/standalone-chrome:latest
alias: chrome
variables:
SE_NODE_OVERRIDE_MAX_SESSIONS: 'true'
SE_NODE_MAX_SESSIONS: '8'
SE_LOG_LEVEL: 'FINE'
Result log: selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes Host info: host: '2f7cc90ad43a', ip: '172.0.0.0' Build info: version: '4.20.0', revision: '866c76ca80' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11' Driver info: driver.version: unknown Stacktrace: at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:220) at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:70) at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147) at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:464) at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:651) at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:570) at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:830) at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:790) at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1) at java.lang.Thread.run (None:-1)
- Options for remote chrome driver in app:
def _chrome_options(browser_mode: str, device_emulation: bool) -> Options:
opt = Options()
opt.add_argument("--no-sandbox")
opt.add_argument("--incognito")
opt.add_argument("--verbose")
opt.add_argument("--ignore-certificate-errors")
opt.add_argument("--start-maximized")
opt.add_experimental_option("excludeSwitches", ["enable-automation"])
opt.add_experimental_option("useAutomationExtension", False)
opt.add_argument("--allow-running-insecure-content")
opt.add_argument("--disable-dev-shm-usage")
opt.add_experimental_option('prefs', {
"download.default_directory": pytest.root_dir, # Change default directory for downloads
"download.prompt_for_download": False, # To auto download the file
"download.directory_upgrade": True,
"plugins.always_open_pdf_externally": True # It will not show PDF directly in chrome
})
opt.page_load_strategy = "normal"
if device_emulation:
opt.add_experimental_option("mobileEmulation", mobile_emulation)
else:
opt.add_argument("--window-size=1920,1080")
if browser_mode != "normal":
opt.add_argument("--headless")
return opt
remote_url = f"http://{browser}:4444"
wd_remote = webdriver.Remote(remote_url, options=self._chrome_options(browser_mode, device_emulation))
@kisuro, is this issue able to reproduce with the recent latest or chrome 125.0 image tag?
If yes, can you provide which version of Docker engine, docker-compose that you are using?
@kisuro, is this issue able to reproduce with the recent
latestor chrome125.0image tag? If yes, can you provide which version of Docker engine, docker-compose that you are using?
Yes, its still reproduce. selenium: 4.21.0 chrome: 125
log:
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: 'bb8d6b99471b', ip: 'xxx.xx.xx.xx'
E Build info: version: '4.21.0', revision: '79ed462ef4'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:652)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:571)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:831)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:791)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
E at java.lang.Thread.run (None:-1)
/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
image: docker:20.10.9
d.compose not in use.
stage: test services: - name: selenium/standalone-chrome:latest
I feel the issue could be with Docker engine 20.10.9. If there is no dependency on upgrading thrid-party, can you try upgrade docker engine to 20.10.24 (the latest patch in major 20.10) and confirm?
I feel the issue could be with Docker engine
20.10.9. If there is no dependency on upgrading thrid-party, can you try upgrade docker engine to20.10.24(the latest patch in major 20.10) and confirm?
Was updated image docker version:
docker_build:
image: docker:20.10.24
stage: build
But result the same: as I can see:
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: '3fdfdc3febf', ip: '***.**.**.**'
E Build info: version: '4.21.0', revision: '79ed42ef4'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:652)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:571)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:831)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:791)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
E at java.lang.Thread.run (None:-1)
/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
@kisuro Perhaps you found a way to solve this problem and could share?
@kisuro Perhaps you found a way to solve this problem and could share?
No. I still have this problem with last version, still using 123.0.6312.86 and hope someone from team help me resolve it
@VietND96, @diemol any update, idea? I still have issues on my side with latest chrome image. docker:20.10.24
logs
Starting service selenium/standalone-chrome:latest...
Pulling docker image selenium/standalone-chrome:latest ...
..
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7fc10a683880>
response = {'status': 500, 'value': '{\n "value": {\n "error": "session not created",\n "message": "Could not start a new ... "className": "java.lang.Thread",\n "lineNumber": -1,\n "classLoaderName": null\n }\n ]\n }\n}'}
def check_response(self, response: Dict[str, Any]) -> None:
"""Checks that a JSON response from the WebDriver does not have an
error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get("status", None)
if not status or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen: str = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get("value", None)
if value_json and isinstance(value_json, str):
import json
try:
value = json.loads(value_json)
if len(value) == 1:
value = value["value"]
status = value.get("error", None)
if not status:
status = value.get("status", ErrorCode.UNKNOWN_ERROR)
message = value.get("value") or value.get("message")
if not isinstance(message, str):
value = message
message = message.get("message")
else:
message = value.get("message", None)
except ValueError:
pass
exception_class: Type[WebDriverException]
e = ErrorCode()
error_codes = [item for item in dir(e) if not item.startswith("__")]
for error_code in error_codes:
error_info = getattr(ErrorCode, error_code)
if isinstance(error_info, list) and status in error_info:
exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
break
else:
exception_class = WebDriverException
if not value:
value = response["value"]
if isinstance(value, str):
raise exception_class(value)
if message == "" and "message" in value:
message = value["message"]
screen = None # type: ignore[assignment]
if "screen" in value:
screen = value["screen"]
stacktrace = None
st_value = value.get("stackTrace") or value.get("stacktrace")
if st_value:
if isinstance(st_value, str):
stacktrace = st_value.split("\n")
else:
stacktrace = []
try:
for frame in st_value:
line = frame.get("lineNumber", "")
file = frame.get("fileName", "<anonymous>")
if line:
file = f"{file}:{line}"
meth = frame.get("methodName", "<anonymous>")
if "className" in frame:
meth = f"{frame['className']}.{meth}"
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == UnexpectedAlertPresentException:
alert_text = None
if "data" in value:
alert_text = value["data"].get("text")
elif "alert" in value:
alert_text = value["alert"].get("text")
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: 'ce833a2c63e9', ip: 'xxx.xx.x.x'
E Build info: version: '4.22.0', revision: 'c5f3146703'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:652)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:571)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:834)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:[79](https://gitlab.devops.telekom.de/oneapp/apps/mavi_automation/mavi_automation/-/jobs/181162486#L79)1)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
E at java.lang.Thread.run (None:-1)
/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
______________________ ERROR at teardown of test_selenium ______________________
self = <allure_commons._allure.fixture object at 0x7fc10a6[83](https://gitlab.xxx)3d0>, args = ()
kwargs = {}
def __call__(self, *args, **kwargs):
self.parameters = func_parameters(self._fixture_function, *args, **kwargs)
with self:
> return self._fixture_function(*args, **kwargs)
/usr/local/lib/python3.10/site-packages/allure_commons/_allure.py:221:
What if you deploy Hub container with env var set SE_JAVA_OPTS=-Djdk.httpclient.keepalive.timeout=300
What if you deploy Hub container with env var set
SE_JAVA_OPTS=-Djdk.httpclient.keepalive.timeout=300
docker:20.10.24 and added SE_JAVA_OPTS still have issue, just change chrome:123.0 to chrome:latest
marked_test:
image: $CONTAINER_TEST_IMAGE
allow_failure: true
stage: test
services:
- name: selenium/standalone-chrome:latest
alias: chrome
variables:
SE_NODE_OVERRIDE_MAX_SESSIONS: 'true'
SE_NODE_MAX_SESSIONS: '8'
SE_JAVA_OPTS: '-Djdk.httpclient.keepalive.timeout=300'
LOG:
/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:212: in __init__
self.start_session(capabilities)
/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:299: in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py:354: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7f5f50c96650>
response = {'status': 500, 'value': '{\n "value": {\n "error": "session not created",\n "message": "Could not start a new ..."className": "java.lang.Thread",\n "lineNumber": 840,\n "classLoaderName": null\n }\n ]\n }\n}'}
def check_response(self, response: Dict[str, Any]) -> None:
"""Checks that a JSON response from the WebDriver does not have an
error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get("status", None)
if not status or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen: str = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get("value", None)
if value_json and isinstance(value_json, str):
import json
try:
value = json.loads(value_json)
if len(value) == 1:
value = value["value"]
status = value.get("error", None)
if not status:
status = value.get("status", ErrorCode.UNKNOWN_ERROR)
message = value.get("value") or value.get("message")
if not isinstance(message, str):
value = message
message = message.get("message")
else:
message = value.get("message", None)
except ValueError:
pass
exception_class: Type[WebDriverException]
e = ErrorCode()
error_codes = [item for item in dir(e) if not item.startswith("__")]
for error_code in error_codes:
error_info = getattr(ErrorCode, error_code)
if isinstance(error_info, list) and status in error_info:
exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
break
else:
exception_class = WebDriverException
if not value:
value = response["value"]
if isinstance(value, str):
raise exception_class(value)
if message == "" and "message" in value:
message = value["message"]
screen = None # type: ignore[assignment]
if "screen" in value:
screen = value["screen"]
stacktrace = None
st_value = value.get("stackTrace") or value.get("stacktrace")
if st_value:
if isinstance(st_value, str):
stacktrace = st_value.split("\n")
else:
stacktrace = []
try:
for frame in st_value:
line = frame.get("lineNumber", "")
file = frame.get("fileName", "<anonymous>")
if line:
file = f"{file}:{line}"
meth = frame.get("methodName", "<anonymous>")
if "className" in frame:
meth = f"{frame['className']}.{meth}"
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == UnexpectedAlertPresentException:
alert_text = None
if "data" in value:
alert_text = value["data"].get("text")
elif "alert" in value:
alert_text = value["alert"].get("text")
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: '07ac380319xx', ip: 'xxx.xx.xx'
E Build info: version: '4.23.0', revision: '77010cd'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:[71](https://gitlab.devops.telekom.de/oneapp/apps/oneshop_automation/oneshop_automation/-/jobs/182540648#L71))
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:654)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:5[73](https://gitlab.devops.telekom.de/oneapp/apps/oneshop_automation/oneshop_automation/-/jobs/182540648#L73))
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:836)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:793)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
E at java.lang.Thread.run (Thread.java:840)
/usr/local/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
Can you also try to use image tag nightly e.g selenium/standalone-chrome:nightly
with env var SE_JAVA_OPTS=-Dwebdriver.httpclient.version=HTTP_1_1
Can you also try to use image tag
nightlye.gselenium/standalone-chrome:nightlywith env varSE_JAVA_OPTS=-Dwebdriver.httpclient.version=HTTP_1_1
Same result.
gitlab-ci.yml
marked_test:
image: $CONTAINER_TEST_IMAGE
allow_failure: true
stage: test
services:
- name: selenium/standalone-chrome:nightly
alias: chrome
variables:
SE_NODE_OVERRIDE_MAX_SESSIONS: 'true'
SE_NODE_MAX_SESSIONS: '5'
SE_JAVA_OPTS: '-Dwebdriver.httpclient.version=HTTP_1_1'
LOG
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x7fb52b0d2770>
response = {'status': 500, 'value': '{\n "value": {\n "error": "session not created",\n "message": "Could not start a new ..."className": "java.lang.Thread",\n "lineNumber": 840,\n "classLoaderName": null\n }\n ]\n }\n}'}
def check_response(self, response: Dict[str, Any]) -> None:
"""Checks that a JSON response from the WebDriver does not have an
error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get("status", None)
if not status or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen: str = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get("value", None)
if value_json and isinstance(value_json, str):
import json
try:
value = json.loads(value_json)
if len(value) == 1:
value = value["value"]
status = value.get("error", None)
if not status:
status = value.get("status", ErrorCode.UNKNOWN_ERROR)
message = value.get("value") or value.get("message")
if not isinstance(message, str):
value = message
message = message.get("message")
else:
message = value.get("message", None)
except ValueError:
pass
exception_class: Type[WebDriverException]
e = ErrorCode()
error_codes = [item for item in dir(e) if not item.startswith("__")]
for error_code in error_codes:
error_info = getattr(ErrorCode, error_code)
if isinstance(error_info, list) and status in error_info:
exception_class = getattr(ExceptionMapping, error_code, WebDriverException)
break
else:
exception_class = WebDriverException
if not value:
value = response["value"]
if isinstance(value, str):
raise exception_class(value)
if message == "" and "message" in value:
message = value["message"]
screen = None # type: ignore[assignment]
if "screen" in value:
screen = value["screen"]
stacktrace = None
st_value = value.get("stackTrace") or value.get("stacktrace")
if st_value:
if isinstance(st_value, str):
stacktrace = st_value.split("\n")
else:
stacktrace = []
try:
for frame in st_value:
line = frame.get("lineNumber", "")
file = frame.get("fileName", "<anonymous>")
if line:
file = f"{file}:{line}"
meth = frame.get("methodName", "<anonymous>")
if "className" in frame:
meth = f"{frame['className']}.{meth}"
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == UnexpectedAlertPresentException:
alert_text = None
if "data" in value:
alert_text = value["data"].get("text")
elif "alert" in value:
alert_text = value["alert"].get("text")
raise exception_class(message, screen, stacktrace, alert_text) # type: ignore[call-arg] # mypy is not smart enough here
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: '5f[75](https://gitlab.xxx.com/-/jobs/182657548#L75)9cf84171', ip: 'xxx.xx.xx'
E Build info: version: '4.23.0', revision: '1ad8846'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.11'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:221)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:654)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:573)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:836)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:[79](https://gitlab.devops.telekom.de/oneapp/apps/mavi_automation/mavi_automation/-/jobs/182657548#L79)3)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
E at java.lang.Thread.run (Thread.java:[84](https://gitlab.devops.telekom.de/oneapp/apps/mavi_automation/mavi_automation/-/jobs/182657548#L84)0)
/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
Ok, how about all the capabilities that you set from binding while creating the RemoteWebDriver?
Ok, how about all the capabilities that you set from binding while creating the RemoteWebDriver?
@staticmethod
def _chrome_options() -> Options:
opt = Options()
opt.add_argument("--no-sandbox")
# incognito disabled. Because in last version of chrome driver we cant disable
# dialogs for save file in incognito
# opt.add_argument("--incognito")
opt.add_argument("--disable-search-engine-choice-screen")
opt.add_argument("--verbose")
opt.add_argument("--ignore-certificate-errors")
opt.add_argument("--start-maximized")
opt.add_experimental_option("excludeSwitches", ["enable-automation"])
opt.add_experimental_option("useAutomationExtension", False)
opt.add_argument("--allow-running-insecure-content")
opt.add_argument("--disable-dev-shm-usage")
opt.add_argument("--max-connections=10")
opt.add_experimental_option('prefs', {
'profile.default_content_setting_values.automatic_downloads': 1,
"download.default_directory": pytest.root_dir, # Change default directory for downloads
"download.prompt_for_download": False, # To auto download the file
"download.directory_upgrade": True,
"plugins.always_open_pdf_externally": True,
"plugins.plugins_disabled": ["Chrome PDF Viewer"],
"safebrowsing.forcedownload_protection_enabled": False,
"download.extensions_to_open": "application/pdf"
})
opt.add_argument("--headless=new")
opt.page_load_strategy = "eager"
remote_url = "http://chrome:4444"
wd_remote = webdriver.Remote(remote_url, options=self._chrome_options())
I feel it could be one of those caps that caused the browser not started properly. To confirm this, can you try a sample run without any options set?
I feel it could be one of those caps that caused the browser not started properly. To confirm this, can you try a sample run without any options set?
Was removed all options except: opt.add_argument("--headless=new")
Result same.
ERROR test/test_routing.py::test_routing - selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
@kisuro, can you check the latest image tag 4.23.1, I suspect that CLI options can be conflicted between SE_OPTS and corresponding env vars, and it is fixed
@kisuro, can you check the latest image tag
4.23.1, I suspect that CLI options can be conflicted between SE_OPTS and corresponding env vars, and it is fixed
Changed Selenium version (requirements.txt):
selenium-4.23.1
updated gitlab-ci.yml lines:
docker:20.10.24
services:
- name: selenium/standalone-chrome:latest
alias: chrome
variables:
SE_NODE_OVERRIDE_MAX_SESSIONS: 'true'
SE_NODE_MAX_SESSIONS: '5'
Result the same :(
E selenium.common.exceptions.SessionNotCreatedException: Message: Could not start a new session. Error while creating session with the driver service. Stopping driver service: java.io.IOException: HTTP/1.1 header parser received no bytes
E Host info: host: 'c45e83617exx', ip: 'xxx.xx.x.x'
E Build info: version: '4.23.1', revision: '656257d8e9'
E System info: os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-91-generic', java.version: '17.0.12'
E Driver info: driver.version: unknown
E Stacktrace:
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:226)
E at org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply (DriverServiceSessionFactory.java:71)
E at org.openqa.selenium.grid.node.local.SessionSlot.apply (SessionSlot.java:147)
E at org.openqa.selenium.grid.node.local.LocalNode.newSession (LocalNode.java:469)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.startSession (LocalDistributor.java:654)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor.newSession (LocalDistributor.java:573)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.handleNewSessionRequest (LocalDistributor.java:836)
E at org.openqa.selenium.grid.distributor.local.LocalDistributor$NewSessionRunnable.lambda$run$1 (LocalDistributor.java:793)
E at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
E at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
E at java.lang.Thread.run (Thread.java:840)
/usr/local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py:229: SessionNotCreatedException
@kisuro I also encountered a similar issue when I set user: root for node-firefox in my docker-compose file. Removing the user: root configuration resolved everything. It's really strange