Selenium Grid 4: Run Tests on Many Browsers and Machines

Selenium 16 min min read Updated: Nov 16, 2026 Advanced
Selenium Grid 4: Run Tests on Many Browsers and Machines
Advanced Topic 1 of 5

What Is Selenium Grid?

Selenium Grid lets you run tests on many machines and browsers at once. Your test talks to the Grid, the Grid picks a free browser on some machine, and runs the commands there.

text Test (pytest -n 4) --> Grid Router --> Node A: Chrome x4 (Linux) --> Node B: Firefox x4 (Linux) --> Node C: Edge x2 (Windows)
ReasonBenefit
SpeedRun 8 tests at the same time
Cross-browserChrome, Firefox and Edge from one suite
Cross-platformWindows, Linux and macOS nodes
Clean machinesTests do not use your laptop

Grid 4 Modes

ModeUse
StandaloneOne machine runs everything. Easiest. Good for local use and learning
Hub and NodeA hub plus several nodes on different machines
DistributedRouter, Distributor, Session Map, Event Bus as separate parts for very large setups

Requirements

  • Java 17 or newer (the Grid server is a Java program)
  • Download selenium-server-<version>.jar from selenium.dev downloads
  • Browsers installed on the machine (Selenium Manager can help with drivers)

Standalone Grid

bash java -jar selenium-server-<version>.jar standalone

Open http://localhost:4444 to see the Grid UI with available browsers and sessions.

Hub and Node

bash # machine 1: the hub java -jar selenium-server-<version>.jar hub # machine 2 and 3: nodes that register with the hub java -jar selenium-server-<version>.jar node --hub http://192.168.1.10:4444
Same machine test: You can run the hub and a node on one computer in two terminals to practice.

Use the Grid from Python

python from selenium import webdriver from selenium.webdriver.chrome.options import Options options = Options() options.add_argument("--window-size=1920,1080") driver = webdriver.Remote( command_executor="http://localhost:4444", options=options) driver.get("https://www.selenium.dev") print(driver.title) driver.quit() # frees the slot on the Grid

Change the options class to switch browsers:

python from selenium.webdriver.firefox.options import Options as FirefoxOptions driver = webdriver.Remote("http://localhost:4444", options=FirefoxOptions())

Choose Platform and Version

python options = Options() options.set_capability("platformName", "linux") options.browser_version = "stable"

Plug into the Framework

Our driver factory from the framework lesson already supports --remote:

bash pytest -n 4 --browser=chrome --remote=http://localhost:4444 pytest -n 4 --browser=firefox --remote=http://localhost:4444

Useful Grid Settings

SettingMeaning
--max-sessions N (node)Number of browsers this node can run at the same time
--session-timeout 300Kill sessions that are idle for 300 seconds. Prevents stuck sessions
--override-max-sessions trueAllow more sessions than CPU cores (use with care)

Troubleshooting

ProblemFix
SessionNotCreatedExceptionNo node supports that browser/version; check the Grid UI
Tests wait in a queueAll slots busy: add nodes or lower the number of workers
Nodes not visible on hubFirewall or wrong hub address; open port 4444 (and 5555/4442/4443 for event bus in some setups)
Sessions never endsAlways call driver.quit(), set a session timeout
In practice: Most teams run Grid in Docker (next lesson) or use a cloud provider, so nobody installs browsers by hand.

Conclusion

The Grid receives sessions from tests and starts browsers on available nodes. Use webdriver.Remote with the Grid URL, call quit() always and combine it with pytest-xdist for fast parallel runs.

Quick Summary: java -jar selenium-server.jar standalone; webdriver.Remote('http://localhost:4444').

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators