Selenium Grid and parallel tests: faster runs without new failures
By Denis Bojkovski, Test Automation Architect · Published November 25, 2026
Independence comes first
Parallel running does not create most of the failures it exposes. It reveals tests that were already sharing a user, a record or a static variable. Before adding machines, run the suite in random order. Any test that fails there will fail in parallel too.
Seven of the 86 full descriptions on QAAnywhere on 25 November 2026 named a grid or a cloud browser service such as BrowserStack, Sauce Labs or LambdaTest.
A grid on your machine
docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome:4.27.0
The shared memory option matters: browsers use it heavily and crash in odd ways when a container has too little. Pin the image version, so an update arrives when you decide, not on a Monday morning. Open http://localhost:4444 to see sessions.
var options = new ChromeOptions();
using var driver = new RemoteWebDriver(new Uri("http://localhost:4444"), options);
One driver per test
A static driver shared between tests is the usual reason parallel runs break. In NUnit, create it per test:
[TestFixture]
[FixtureLifeCycle(LifeCycle.InstancePerTestCase)]
[Parallelizable(ParallelScope.All)]
public class SearchTests
{
private IWebDriver driver = null!;
[SetUp]
public void Start() => driver =
new RemoteWebDriver(new Uri("http://localhost:4444"), new ChromeOptions());
[TearDown]
public void Stop() { driver.Quit(); driver.Dispose(); }
}
Without InstancePerTestCase, NUnit shares one fixture object, so parallel tests would overwrite the same field. Limit the workers with [assembly: LevelOfParallelism(4)].
Sizing
Start with one browser session per processor core and watch the machine. When processor use is pinned, more sessions make every test slower and produce timeouts that look like product faults. Measure total time at 2, 4, 6 and 8 sessions; the curve flattens, and the point just before that is your setting.
The application under test can also be the limit. If the test environment runs on one small server, four parallel browsers may be its ceiling.
Amdahl's law for test suites
If one test takes eight minutes, the suite cannot finish faster than eight minutes. List the ten slowest tests. Splitting one long journey into independent tests often saves more than doubling the hardware.
Cloud or your own grid?
| Need | Better fit |
|---|---|
| Chrome and Firefox on Linux | Your own containers |
| Safari on macOS, older versions | Cloud service |
| Real phones | Cloud service or device lab |
| Data that must not leave your network | Your own grid |
| Nobody has time to maintain machines | Cloud service |
Cloud services charge by parallel session, so a queue may form at busy hours. Run the bulk on your own containers and only a small cross-browser set in the cloud.
Keep the matrix honest
Running every test in four browsers multiplies cost and noise. Look at real visitor statistics. Usually the whole suite belongs on one browser, with a short set of layout, input and media tests on the rest, because that is where browsers differ.
Checks before you call it done
- The suite passes ten consecutive parallel runs.
- Sessions close when a test crashes; no orphans after an hour.
- Reports show which node ran each test.
- One command runs the same suite without the grid, for debugging.
Related: Selenium waits explained and Docker for testers.