Implementation:SeleniumHQ Selenium Standalone And Hub Commands
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Testing, Architecture, Selenium_Grid |
| Last Updated | 2026-02-11 00:00 GMT |
Overview
Concrete tool for selecting and running Grid deployment topologies provided by the Selenium Grid CLI commands.
Description
The Standalone and Hub classes both extend TemplateGridServerCommand and implement the CliCommand interface, registered via @AutoService(CliCommand.class) for ServiceLoader discovery. Standalone creates all Grid components in a single process: it instantiates LocalSessionMap, LocalNewSessionQueue, LocalDistributor, Router, GraphqlHandler, and GridUiRoute, plus a local Node via NodeOptions.getNode(). Hub creates the same central components (Router, Distributor, Session Map, Session Queue, Event Bus) but omits the local Node, expecting separate Node processes to connect. Both commands support an optional readinessCheck at the /readyz endpoint for Kubernetes liveness probes.
Usage
Invoke via the Grid server JAR: java -jar selenium-server.jar standalone or java -jar selenium-server.jar hub. Configuration via TOML file or CLI flags.
Code Reference
Source Location
- Repository: Selenium
- File: java/src/org/openqa/selenium/grid/commands/Standalone.java (L80-288)
- File: java/src/org/openqa/selenium/grid/commands/Hub.java (L73-247)
Signature
@AutoService(CliCommand.class)
public class Standalone extends TemplateGridServerCommand {
// getName() returns "standalone"
// getDescription() returns "The selenium server, running everything in-process."
public Set<Role> getConfigurableRoles(); // DISTRIBUTOR, EVENT_BUS, HTTPD, NODE, ROUTER, SESSION_QUEUE
protected Handlers createHandlers(Config config);
protected void execute(Config config);
}
@AutoService(CliCommand.class)
public class Hub extends TemplateGridServerCommand {
// getName() returns "hub"
// getDescription() returns "A grid hub, composed of sessions, distributor, and router."
public Set<Role> getConfigurableRoles(); // DISTRIBUTOR, EVENT_BUS, HTTPD, SESSION_QUEUE, ROUTER
protected Handlers createHandlers(Config config);
protected void execute(Config config);
}
Import
// These are CLI entry points, not directly imported in user code
// Invoked via: java -jar selenium-server.jar standalone|hub|node
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| CLI command | String | Yes | "standalone", "hub", "node", "distributor", "router", "sessions", "sessionqueue" |
| --config | File path | No | TOML configuration file |
| --port | int | No | HTTP server port (default: 4444) |
| --host | String | No | Hostname to bind to |
| --max-sessions | int | No | Maximum concurrent sessions per node |
Outputs
| Name | Type | Description |
|---|---|---|
| Grid Server | HTTP Server | Running Grid on configured port, accepting WebDriver sessions |
| /status | JSON | Grid status endpoint reporting readiness and node info |
| /readyz | Text | Kubernetes-compatible liveness probe endpoint |
| /ui | HTML | Grid web UI (can be disabled via RouterOptions.disableUi()) |
Usage Examples
Standalone Mode
# Start all-in-one Grid
java -jar selenium-server.jar standalone --port 4444
# With TOML config
java -jar selenium-server.jar standalone --config grid-config.toml
Hub-and-Node Mode
# Start Hub
java -jar selenium-server.jar hub --port 4444
# Start Node (on same or different machine)
java -jar selenium-server.jar node --hub http://hub-host:4444