-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
What happened?
I have a basic use case involving network interception through "IWebDriver.Manage().Network" and using a "NetworkRequestHandler". This works without issue when pointing the project to a local driver (ChromeDriver) or a direct execution of the Selenium Server jar (through RemoteWebDriver). This is failing when attempt to use the same setup via Docker or K8s. I'm sure something is just not being exposed, but I've been unable to troubleshoot what is missing.
While the test is running, I am able to get into the container/pod and execute a "curl http://localhost:9222/json/version" request with a valid response which confirms that the browser itself was able to open the debugging session, but then the test hangs for 30 seconds and claims that it timed out waiting for confirmation that a connection has been established.
Any help would be greatly appreciated because from my perspective it really seems like everything should be in place to allow this to happen.
I have a repo isolated with the basic setup that reproduces the discrepancy and a basic readme for reproduction steps.
Command used to start Selenium Grid with Docker (or Kubernetes)
All steps noted here: https://github.com/btvanhooser/selenium-grid-cdp-issue
For at a glance inspection, here is the docker compose file for the docker case:
services:
chrome:
image: selenium/node-chrome:4.34.0-20250707
platform: linux/amd64
shm_size: 2gb
depends_on:
- selenium-hub
environment:
- SE_VNC_NO_PASSWORD=true
- SE_EVENT_BUS_HOST=selenium-hub
- SE_NODE_GRID_URL=http://selenium-hub:4444/
- SE_NODE_ENABLE_CDP=true
ports:
- "5555:5555"
selenium-hub:
image: selenium/hub:4.34.0-20250707
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
Relevant log output
Exception from the test project:
OpenQA.Selenium.WebDriverException : Unexpected error creating WebSocket DevTools session.
----> System.TimeoutException : Could not connect to browser within 30 seconds
Response from in-container/in-pod curl request to the CDP endpoint:
(venv) seluser@a81e588f0518:/$ curl http://localhost:9222/json/version
{
"Browser": "Chrome/138.0.7204.100",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
"V8-Version": "13.8.500258",
"WebKit-Version": "537.36 (@5f45b4744e3d5ba82c2ca6d942f1e7a516110752)",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/browser/86703501-8fac-4e0c-a8d0-8f3fb8f785d3"
}
Operating System
Windows 11, Podman Desktop, Kind (for local K8s cluster)
Docker Selenium version (image tag)
4.34.0-20250707
Selenium Grid chart version (chart version)
0.45.1