Selenium Grid 4 Setup: Hub, Nodes, Docker, and Kubernetes Deployment Guide
Selenium Grid 4 is a complete rewrite — new architecture, Docker support, Kubernetes scaling. If you are still on Grid 3, migration is overdue. Here is the complete setup.
🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.
Contents
Grid 4 Architecture
Grid 4 Components:
Router ─── Distributor ─── Session Map
|
┌───────┼───────┐
Node Node Node
(Chrome) (Firefox) (Edge)
Docker Compose Setup
version: '3.8'
services:
selenium-hub:
image: selenium/hub:4.18.0
ports: ['4442:4442', '4443:4443', '4444:4444']
chrome:
image: selenium/node-chrome:4.18.0
depends_on: [selenium-hub]
environment:
SE_EVENT_BUS_HOST: selenium-hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
SE_NODE_MAX_SESSIONS: 4
shm_size: '2gb'
firefox:
image: selenium/node-firefox:4.18.0
depends_on: [selenium-hub]
environment:
SE_EVENT_BUS_HOST: selenium-hub
SE_EVENT_BUS_PUBLISH_PORT: 4442
SE_EVENT_BUS_SUBSCRIBE_PORT: 4443
Standalone Mode (Simplest)
# Single container with Chrome + Firefox + Edge
docker run -d -p 4444:4444 -p 7900:7900 --shm-size 2g selenium/standalone-chrome:4.18.0
# Connect your tests
# Set remote URL: http://localhost:4444
🚀 Level Up Your Playwright
From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.
Grid 3 vs Grid 4
| Feature | Grid 3 | Grid 4 |
|---|---|---|
| Architecture | Hub + Node | Router + Distributor + Node |
| Docker support | Community images | Official images |
| Kubernetes | Manual | Native KEDA autoscaling |
| Observability | None | GraphQL API + /status |
| Video recording | External | Built-in per node |
| Protocol | JSON Wire | W3C WebDriver |
Kubernetes Deployment
# Using Helm chart
helm repo add docker-selenium https://www.selenium.dev/docker-selenium
helm install selenium-grid docker-selenium/selenium-grid \
--set chromeNode.replicas=3 \
--set firefoxNode.replicas=2
When Grid 4 vs Playwright
- Grid 4: Existing Selenium suite, need cross-browser at scale, Java/Python team
- Playwright: New project, built-in parallelism, no Grid infrastructure needed
- Cloud (BrowserStack/Sauce Labs): No infra to maintain, pay-per-use, real devices
🎓 Master Playwright End to End
Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.
