Skip to content
SDETRole
SDETRole

Glossary · UI automation

Selenium Grid

Also called: Selenium Grid 4

Definition

A Selenium server that routes WebDriver sessions to remote browser nodes, so tests can run in parallel across many browsers, versions and machines.

Selenium Grid lets a test create its browser somewhere else. The test uses RemoteWebDriver and points it at the Grid’s URL; the Grid finds a node with a matching browser (for example, Chrome on Linux), starts a session there, and relays every command. Because many nodes can serve sessions at once, Grid is the classic way to run a Selenium suite in parallel and across browsers.

Example

Start a single-machine Grid with the official Docker image:

docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome

Then connect from a test (Selenium 4, Java 21):

ChromeOptions options = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(
    URI.create("http://localhost:4444").toURL(), options);

driver.get("https://example.com");

The browser options are the “capabilities” the Grid matches against its nodes. The Grid UI at http://localhost:4444 shows nodes, slots and running sessions.

How it is structured (Grid 4)

Selenium Grid 4 can run in three modes:

  • Standalone: everything in one process, good for local use and small CI jobs.
  • Hub and node: one hub receives sessions and several nodes run browsers. Start with java -jar selenium-server-<version>.jar hub and ... node.
  • Fully distributed: the hub’s internal components (Router, Distributor, Session Map, New Session Queue, Event Bus) run as separate processes, which suits Kubernetes.

Grid 4 also removed the need for the old /wd/hub path, though it still accepts it.

Common mistakes

  • Expecting Grid to make tests parallel. Grid supplies browsers. Your test runner (JUnit 5, TestNG) must still be configured to run tests concurrently, and tests must be isolated.
  • More threads than slots. Extra session requests queue and can time out. Match runner parallelism to available slots.
  • Not quitting drivers. A missing driver.quit() leaves sessions occupying slots until they time out.
  • Small shared memory in Docker. Chrome crashes with the default container /dev/shm, hence the --shm-size flag.

Hosted cloud services expose the same WebDriver endpoint as a Grid, so the RemoteWebDriver code is identical; only the URL and capabilities change.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →