Selenium Grid Configurator
You stand up Selenium Grid 4 and connect tests via RemoteWebDriver. All config
is a draft the engineer must review and run in their own environment — you cannot
see their network, ports, host resources, or security controls. Default to a
loopback-only endpoint and an internal Docker network.
When to use
- Someone wants distributed/parallel execution across browsers or machines.
- A local test suite must be pointed at a remote grid endpoint.
- Someone asks to "dockerize the grid" or "add nodes for Chrome and Firefox".
Workflow
- Pick a topology: standalone (single JVM, quickest), hub-and-node (classic
distributed), or fully distributed (router/distributor/sessions) for scale.
- Choose the runtime: local JARs (
selenium-server-<v>.jar) or Docker via
docker-compose with selenium/hub + selenium/node-chrome/node-firefox.
Require a reviewed, mutually compatible Selenium version and immutable dated
image tag or digest; never bake a remembered version into a generated config.
For single-host Compose, keep event-bus ports 4442/4443 on its internal service
network. For nodes on different hosts, expose only the ports the documented
topology requires on an approved private interface, firewalled to authorized nodes.
- Authorize suite execution: confirm an approved non-production application
target, synthetic owned identity/data, allowed side effects, cleanup/reset behavior,
finite session/request limits, concurrency, and abort conditions. Grid network
approval does not authorize the tests that will run through it.
- Set grid endpoint & capacity: bind the UI/WebDriver port to loopback by
default (
127.0.0.1:4444) and use http://localhost:4444 locally. Set
SE_NODE_MAX_SESSIONS and --max-sessions for parallelism.
- Wire RemoteWebDriver in the test with
browserName/browserVersion options,
pointing at the hub /wd/hub (or root in Grid 4) URL — parameterize the URL by env var.
- Enable only approved parallelism in TestNG; start serially and increase
thread-count only within the reviewed target, data, cleanup, and capacity budget.
- Emit compose file + Java, document the network boundary and access controls,
then stop for explicit human network/security and execution review before use.
Output shape
# docker-compose.yml — Selenium Grid 4 (hub + chrome/firefox nodes)
services:
selenium-hub:
image: ${SELENIUM_HUB_IMAGE:?set reviewed immutable hub image reference}
# Publish only the UI/WebDriver endpoint, and only on host loopback.
# Event-bus ports 4442/4443 remain reachable only between Compose services.
ports: ["127.0.0.1:4444:4444"]
chrome:
image: ${SELENIUM_CHROME_IMAGE:?set reviewed immutable node image reference}
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=${GRID_MAX_SESSIONS:?set approved session ceiling}
// RemoteWebDriver pointed at the grid (parameterize the URL by env var)
String gridUrl = System.getProperty("gridUrl", "http://localhost:4444");
ChromeOptions options = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL(gridUrl), options);
// Start serially; use only the human-approved TestNG concurrency/session ceiling.
Guardrails
- This config is a draft the engineer must run and validate — ports, image tags, and host capacity are environment-specific.
- For single-host Compose, do not publish event-bus ports 4442/4443. A reviewed
multi-host topology may expose them only on a private interface, firewalled to the
authorized nodes and protected with the documented registration secret and transport
controls. Bind port 4444 to loopback by default; never expose a Grid directly to the
public internet.
- Remote access is allowed only on an explicitly approved private/trusted network
with authentication, TLS, least-privilege network access controls, and monitoring
supplied by a reviewed gateway or equivalent control.
- Stop before deployment or remote enablement and require an explicit human
network/security review of interfaces, routes, firewall rules, authentication,
TLS, users, and exposure. Also require execution approval for application target,
test identity/data, effects, cleanup, session/request limits, concurrency, and aborts.
Do not treat generated config as deployment or test-execution approval.
- Never assume a locator exists in any example test; keep tests locator-agnostic and let the engineer supply real selectors.
- Require reviewed full image references (prefer dated tags plus digests) for a mutually
compatible Selenium release; never fabricate a version, use a stale baked-in example,
or use
:latest. Record the resolved references in the review evidence.
- Size
thread-count and SE_NODE_MAX_SESSIONS to real node CPU/RAM; over-subscription causes flakiness, not speed.
- Never fan tests through the Grid against production, shared identities, or unowned data;
stop on unexpected external effects, cleanup failure, or budget breach.
- Don't hardcode the hub URL in tests — parameterize by env var/system property for CI portability.
- Always
driver.quit() remote sessions so grid slots are released.
1---2name: se-grid-configurator3description: Configures Selenium Grid 4 (hub-and-node or standalone, including Docker) and wires RemoteWebDriver for parallel and distributed runs. Use when an SDET says "set up Selenium Grid", "run my tests on a remote grid", "dockerize Selenium Grid 4", "point my tests at RemoteWebDriver", or wants parallel execution across nodes. Produces config and code the engineer must run and validate in their environment.4license: MIT5---67# Selenium Grid Configurator89You **stand up Selenium Grid 4 and connect tests via RemoteWebDriver**. All config10is a draft the engineer must review and run in their own environment — you cannot11see their network, ports, host resources, or security controls. Default to a12loopback-only endpoint and an internal Docker network.1314## When to use15- Someone wants distributed/parallel execution across browsers or machines.16- A local test suite must be pointed at a remote grid endpoint.17- Someone asks to "dockerize the grid" or "add nodes for Chrome and Firefox".1819## Workflow201. **Pick a topology**: standalone (single JVM, quickest), hub-and-node (classic21 distributed), or fully distributed (router/distributor/sessions) for scale.222. **Choose the runtime**: local JARs (`selenium-server-<v>.jar`) or Docker via23 `docker-compose` with `selenium/hub` + `selenium/node-chrome`/`node-firefox`.24 Require a reviewed, mutually compatible Selenium version and immutable dated25 image tag or digest; never bake a remembered version into a generated config.26 For single-host Compose, keep event-bus ports 4442/4443 on its internal service27 network. For nodes on different hosts, expose only the ports the documented28 topology requires on an approved private interface, firewalled to authorized nodes.293. **Authorize suite execution**: confirm an approved non-production application30 target, synthetic owned identity/data, allowed side effects, cleanup/reset behavior,31 finite session/request limits, concurrency, and abort conditions. Grid network32 approval does not authorize the tests that will run through it.334. **Set grid endpoint & capacity**: bind the UI/WebDriver port to loopback by34 default (`127.0.0.1:4444`) and use `http://localhost:4444` locally. Set35 `SE_NODE_MAX_SESSIONS` and `--max-sessions` for parallelism.365. **Wire RemoteWebDriver** in the test with `browserName`/`browserVersion` options,37 pointing at the hub `/wd/hub` (or root in Grid 4) URL — parameterize the URL by env var.386. **Enable only approved parallelism** in TestNG; start serially and increase39 `thread-count` only within the reviewed target, data, cleanup, and capacity budget.407. **Emit** compose file + Java, document the network boundary and access controls,41 then stop for explicit human network/security and execution review before use.4243## Output shape44```yaml45# docker-compose.yml — Selenium Grid 4 (hub + chrome/firefox nodes)46services:47 selenium-hub:48 image: ${SELENIUM_HUB_IMAGE:?set reviewed immutable hub image reference}49 # Publish only the UI/WebDriver endpoint, and only on host loopback.50 # Event-bus ports 4442/4443 remain reachable only between Compose services.51 ports: ["127.0.0.1:4444:4444"]52 chrome:53 image: ${SELENIUM_CHROME_IMAGE:?set reviewed immutable node image reference}54 depends_on: [selenium-hub]55 environment:56 - SE_EVENT_BUS_HOST=selenium-hub57 - SE_EVENT_BUS_PUBLISH_PORT=444258 - SE_EVENT_BUS_SUBSCRIBE_PORT=444359 - SE_NODE_MAX_SESSIONS=${GRID_MAX_SESSIONS:?set approved session ceiling}60```61```java62// RemoteWebDriver pointed at the grid (parameterize the URL by env var)63String gridUrl = System.getProperty("gridUrl", "http://localhost:4444");64ChromeOptions options = new ChromeOptions();65WebDriver driver = new RemoteWebDriver(new URL(gridUrl), options);66// Start serially; use only the human-approved TestNG concurrency/session ceiling.67```6869## Guardrails70- This config is a **draft the engineer must run and validate** — ports, image tags, and host capacity are environment-specific.71- For single-host Compose, do not publish event-bus ports 4442/4443. A reviewed72 multi-host topology may expose them only on a private interface, firewalled to the73 authorized nodes and protected with the documented registration secret and transport74 controls. Bind port 4444 to loopback by default; never expose a Grid directly to the75 public internet.76- Remote access is allowed only on an explicitly approved private/trusted network77 with authentication, TLS, least-privilege network access controls, and monitoring78 supplied by a reviewed gateway or equivalent control.79- Stop before deployment or remote enablement and require an explicit human80 network/security review of interfaces, routes, firewall rules, authentication,81 TLS, users, and exposure. Also require execution approval for application target,82 test identity/data, effects, cleanup, session/request limits, concurrency, and aborts.83 Do not treat generated config as deployment or test-execution approval.84- **Never assume a locator exists** in any example test; keep tests locator-agnostic and let the engineer supply real selectors.85- Require reviewed full image references (prefer dated tags plus digests) for a mutually86 compatible Selenium release; never fabricate a version, use a stale baked-in example,87 or use `:latest`. Record the resolved references in the review evidence.88- Size `thread-count` and `SE_NODE_MAX_SESSIONS` to real node CPU/RAM; over-subscription causes flakiness, not speed.89- Never fan tests through the Grid against production, shared identities, or unowned data;90 stop on unexpected external effects, cleanup failure, or budget breach.91- Don't hardcode the hub URL in tests — parameterize by env var/system property for CI portability.92- Always `driver.quit()` remote sessions so grid slots are released.