Selenium · Browser automation foundations

How does Selenium Grid work and how do you use it?

Hardgridremote webdriverscalingUpdated Oct 2026
Quiz this track

Short answer

Grid receives a session request, matches its capabilities against registered nodes, and routes commands to a node that provides the requested browser. Clients use RemoteWebDriver pointed at the Grid URL.

Selenium 4 Grid uses a hub-and-node model with a router, session map, distributor and node processes. The router accepts HTTP commands, the distributor queues sessions, and nodes advertise browser capabilities. Grid does not make tests parallel by itself; the runner decides how many sessions to request.

java
ChromeOptions options = new ChromeOptions();
options.setBrowserVersion("stable");
options.setPlatformName("linux");

WebDriver driver = new RemoteWebDriver(
    new URL("http://grid.example.com:4444"),
    options);

try {
    driver.get("https://example.com");
    Assert.assertTrue(driver.getTitle().contains("Example"));
} finally {
    driver.quit();
}
The same test works locally or remotely by changing the driver endpoint and capabilities.
  • Capabilities determine which node can satisfy a session request
  • If no node matches, the session stays queued or fails after the configured timeout
  • A node can run multiple browser slots depending on CPU and memory
  • The session map tracks active sessions so commands reach the right node
  • Grid nodes are usually containers in modern deployments, often via Docker Selenium
  • Video, VNC and logs can be enabled per node for debugging

Size the Grid from observed concurrency and test duration, not from the number of test methods. Each browser slot consumes significant memory. A Grid with too few slots creates long queues that look like slow tests, and a Grid with too many slots on one host causes browser crashes and timeouts.

Grid is not a test runner and does not distribute a single test method. Parallelism comes from TestNG, JUnit, pytest or another runner creating concurrent sessions.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1What happens when no Grid node matches the capabilities?
  2. 2How do you size a Grid for a suite?
  3. 3What is the difference between the router and the distributor?
  4. 4How do you debug a session that is stuck in the queue?

Say it in the interview

Grid receives a session request, matches capabilities against registered nodes and routes all later commands to the chosen node. I point RemoteWebDriver at the Grid URL and keep capabilities explicit. Grid does not create parallelism by itself; the test runner decides how many sessions to open. I size it from real concurrency and memory, and I use Docker nodes with VNC and logs for debugging.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Selenium mock interview and get scored feedback on depth, clarity and confidence.