Selenium Grid Testing Farm
Browser testing infrastructure with Selenium Grid and multiple browsers.
Overview
Selenium Grid is a distributed testing framework that allows automated browser tests to run simultaneously across multiple machines and browsers. Originally developed to solve the scalability limitations of single-instance Selenium WebDriver testing, Selenium Grid operates on a hub-node architecture where the selenium-hub acts as a central registry and router, while browser nodes (chrome-node, firefox-node, edge-node) provide actual browser automation capabilities. This distributed approach enables massive parallel test execution and cross-browser validation at scale.
This Selenium Grid stack creates a robust browser testing farm with dedicated Chrome, Firefox, and Edge nodes connected through an event bus system. The selenium-hub coordinates test distribution using ports 4442 and 4443 for internal communication, while exposing the grid interface on port 4444. Each browser node can handle multiple concurrent sessions, with Chrome and Firefox nodes scaled to two replicas each for increased throughput. The integrated video recording service captures test execution footage for debugging and compliance purposes.
Development teams managing large test suites, QA departments requiring cross-browser validation, and organizations implementing continuous integration pipelines will benefit from this infrastructure. The configuration supports up to 16 simultaneous sessions across multiple browser types, making it ideal for teams that need to validate web applications across different browser engines simultaneously. This setup eliminates the bottleneck of sequential browser testing while providing visual feedback through recorded test sessions.
Key Features
- Event bus architecture with dedicated publish/subscribe ports for efficient test distribution
- Multi-browser node support with Chrome, Firefox, and Edge automation capabilities
- Session-based load balancing with configurable maximum sessions per node
- Horizontal scaling through Docker replicas for Chrome and Firefox nodes
- Integrated video recording with automatic file naming for test session capture
- Grid web interface for real-time monitoring of node status and active sessions
- Timeout management with 300-second session limits to prevent hanging tests
- Independent browser engine isolation preventing cross-contamination between test runs
Common Use Cases
- 1Cross-browser compatibility testing for web applications across Chrome, Firefox, and Edge
- 2Parallel execution of large Selenium test suites to reduce CI/CD pipeline duration
- 3Remote browser automation for teams working with headless server environments
- 4Load testing web applications with multiple concurrent browser sessions
- 5Automated regression testing with video evidence for bug reproduction
- 6Multi-tenant testing infrastructure for development teams sharing browser resources
- 7Integration testing for web applications requiring multiple browser contexts simultaneously
Prerequisites
- Docker Engine with at least 8GB RAM available for multiple browser node containers
- Network ports 4442, 4443, and 4444 available for Selenium Grid communication
- Understanding of Selenium WebDriver RemoteWebDriver configuration and capabilities
- Sufficient disk space in ./videos directory for video recording storage
- Basic knowledge of browser automation and test framework integration
- Docker Compose version supporting deploy.replicas for node scaling
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 selenium-hub: 3 image: selenium/hub:latest4 ports: 5 - "4442:4442"6 - "4443:4443"7 - "4444:4444"8 environment: 9 - GRID_MAX_SESSION=1610 - GRID_TIMEOUT=30011 networks: 12 - selenium_net1314 chrome: 15 image: selenium/node-chrome:latest16 environment: 17 - SE_EVENT_BUS_HOST=selenium-hub18 - SE_EVENT_BUS_PUBLISH_PORT=444219 - SE_EVENT_BUS_SUBSCRIBE_PORT=444320 - SE_NODE_MAX_SESSIONS=421 depends_on: 22 - selenium-hub23 networks: 24 - selenium_net25 deploy: 26 replicas: 22728 firefox: 29 image: selenium/node-firefox:latest30 environment: 31 - SE_EVENT_BUS_HOST=selenium-hub32 - SE_EVENT_BUS_PUBLISH_PORT=444233 - SE_EVENT_BUS_SUBSCRIBE_PORT=444334 - SE_NODE_MAX_SESSIONS=435 depends_on: 36 - selenium-hub37 networks: 38 - selenium_net39 deploy: 40 replicas: 24142 edge: 43 image: selenium/node-edge:latest44 environment: 45 - SE_EVENT_BUS_HOST=selenium-hub46 - SE_EVENT_BUS_PUBLISH_PORT=444247 - SE_EVENT_BUS_SUBSCRIBE_PORT=444348 - SE_NODE_MAX_SESSIONS=449 depends_on: 50 - selenium-hub51 networks: 52 - selenium_net5354 video: 55 image: selenium/video:latest56 environment: 57 - DISPLAY_CONTAINER_NAME=chrome58 - SE_VIDEO_FILE_NAME=auto59 volumes: 60 - ./videos:/videos61 depends_on: 62 - chrome63 networks: 64 - selenium_net6566networks: 67 selenium_net: .env Template
.env
1# Selenium Grid2# Hub at http://localhost:44443# Grid console at http://localhost:4444/uiUsage Notes
- 1Grid UI at http://localhost:4444/ui
- 2Connect tests to http://localhost:4444
- 3Chrome, Firefox, Edge nodes
- 4Video recording available
- 5Scale nodes as needed
Individual Services(5 services)
Copy individual services to mix and match with your existing compose files.
selenium-hub
selenium-hub:
image: selenium/hub:latest
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
environment:
- GRID_MAX_SESSION=16
- GRID_TIMEOUT=300
networks:
- selenium_net
chrome
chrome:
image: selenium/node-chrome:latest
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=4
depends_on:
- selenium-hub
networks:
- selenium_net
deploy:
replicas: 2
firefox
firefox:
image: selenium/node-firefox:latest
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=4
depends_on:
- selenium-hub
networks:
- selenium_net
deploy:
replicas: 2
edge
edge:
image: selenium/node-edge:latest
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
- SE_NODE_MAX_SESSIONS=4
depends_on:
- selenium-hub
networks:
- selenium_net
video
video:
image: selenium/video:latest
environment:
- DISPLAY_CONTAINER_NAME=chrome
- SE_VIDEO_FILE_NAME=auto
volumes:
- ./videos:/videos
depends_on:
- chrome
networks:
- selenium_net
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 selenium-hub:5 image: selenium/hub:latest6 ports:7 - "4442:4442"8 - "4443:4443"9 - "4444:4444"10 environment:11 - GRID_MAX_SESSION=1612 - GRID_TIMEOUT=30013 networks:14 - selenium_net1516 chrome:17 image: selenium/node-chrome:latest18 environment:19 - SE_EVENT_BUS_HOST=selenium-hub20 - SE_EVENT_BUS_PUBLISH_PORT=444221 - SE_EVENT_BUS_SUBSCRIBE_PORT=444322 - SE_NODE_MAX_SESSIONS=423 depends_on:24 - selenium-hub25 networks:26 - selenium_net27 deploy:28 replicas: 22930 firefox:31 image: selenium/node-firefox:latest32 environment:33 - SE_EVENT_BUS_HOST=selenium-hub34 - SE_EVENT_BUS_PUBLISH_PORT=444235 - SE_EVENT_BUS_SUBSCRIBE_PORT=444336 - SE_NODE_MAX_SESSIONS=437 depends_on:38 - selenium-hub39 networks:40 - selenium_net41 deploy:42 replicas: 24344 edge:45 image: selenium/node-edge:latest46 environment:47 - SE_EVENT_BUS_HOST=selenium-hub48 - SE_EVENT_BUS_PUBLISH_PORT=444249 - SE_EVENT_BUS_SUBSCRIBE_PORT=444350 - SE_NODE_MAX_SESSIONS=451 depends_on:52 - selenium-hub53 networks:54 - selenium_net5556 video:57 image: selenium/video:latest58 environment:59 - DISPLAY_CONTAINER_NAME=chrome60 - SE_VIDEO_FILE_NAME=auto61 volumes:62 - ./videos:/videos63 depends_on:64 - chrome65 networks:66 - selenium_net6768networks:69 selenium_net:70EOF7172# 2. Create the .env file73cat > .env << 'EOF'74# Selenium Grid75# Hub at http://localhost:444476# Grid console at http://localhost:4444/ui77EOF7879# 3. Start the services80docker compose up -d8182# 4. View logs83docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/selenium-grid-complete/run | bashTroubleshooting
- Browser node shows 'Unable to connect to hub' error: Verify selenium-hub container is running and SE_EVENT_BUS_HOST environment variable matches service name
- Tests fail with 'SessionNotCreatedException': Check node capacity by visiting grid UI at localhost:4444 and verify SE_NODE_MAX_SESSIONS settings
- Video recording produces empty files: Ensure DISPLAY_CONTAINER_NAME matches actual browser container name and ./videos directory has write permissions
- Grid timeout errors during long-running tests: Increase GRID_TIMEOUT environment variable beyond default 300 seconds
- Chrome or Firefox nodes fail to start: Verify sufficient system memory and check Docker logs for browser initialization errors
- Hub becomes unresponsive under load: Reduce GRID_MAX_SESSION value or increase Docker memory limits for selenium-hub container
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
selenium-hubchrome-nodefirefox-nodeedge-node
Tags
#selenium#testing#browser#automation#grid
Category
Development ToolsAd Space
Shortcuts: C CopyF FavoriteD Download