What does setting SELENIUM_REMOTE_URL do to a Playwright run during a migration?
answer
- An environment variable, not a config key
- The session comes from a hub instead
- Chromium-based browsers only
- Companion variables for headers and capabilities
- Experimental transitional bridge, not architecture
basics
~20 sIt routes Chromium through a Selenium Grid hub instead of launching it locally. Playwright asks the grid for a browser session and drives it over the Chrome DevTools Protocol. The bridge is experimental and covers Chromium only.
solid answer
~40 sSetting the `SELENIUM_REMOTE_URL` environment variable to a Selenium Grid 4 hub tells Playwright to obtain its **Chromium** session from that grid rather than starting a local browser; it then drives the remote browser over the Chrome DevTools Protocol, and your test code is unchanged. `SELENIUM_REMOTE_HEADERS` adds headers for a hub behind authentication and `SELENIUM_REMOTE_CAPABILITIES` passes extra capabilities. Playwright documents this as **experimental**: it can change or be withdrawn, it covers only Chromium-based browsers, and Firefox or WebKit projects gain nothing from it. During a migration it exists so ported tests can run on infrastructure the team has not decommissioned yet — a transitional bridge, not a target architecture, since Playwright's own model is to run bundled browsers locally in parallel workers.
code
bash · 3 linesexport SELENIUM_REMOTE_URL=http://grid.internal:4444
export SELENIUM_REMOTE_HEADERS='{"Authorization":"Basic ZGVtbzpkZW1v"}'
DEBUG=pw:browser* npx playwright test --project=chromiumgo deeper
Just hold the shape: an environment variable pointing at a grid hub makes Playwright get its Chromium from there instead of starting one locally, with no change to the tests.
Explain the mechanics. Playwright requests a session from the hub and then drives that browser over the DevTools Protocol, which is why only Chromium-based browsers are covered.
Show the operational reading: experimental status, single engine, network latency per interaction, and version skew on the node presenting as flakiness. Know how to split a session failure from a connection failure.
Treat it as a dated bridge with an exit. Decide what it buys the migration window, keep the pinned version stable while it is in use, and plan its retirement alongside the infrastructure it is propping up.
`SELENIUM_REMOTE_URL` is the one place where a Playwright run reaches out to a Selenium Grid, and it exists mainly to unblock a migration that is not finished yet. ## What the variable does Set the variable to a Grid 4 hub address before running the suite: - Playwright requests a browser session from the hub instead of launching a browser on the machine running the tests. - It then connects to that remote browser over the **Chrome DevTools Protocol** and drives it exactly as it would drive a local one. - No test code changes. Locators, assertions, fixtures and reporters are unaffected, because only the transport to the browser moved. Two companion variables round it out: `SELENIUM_REMOTE_HEADERS` supplies extra HTTP headers, which is how you get past a hub sitting behind authentication, and `SELENIUM_REMOTE_CAPABILITIES` passes additional capabilities into the session request. ## The limits that decide whether it helps This is documented as experimental, and treating it as a supported production path is the mistake to avoid in an interview answer: - **Chromium only.** Chromium-based browsers are what the bridge covers; Firefox and WebKit projects are not served by it, so cross-engine coverage still has to run locally or in a container. - **Experimental status.** The behaviour may change between releases, so pinning the Playwright version matters more than usual if a pipeline leans on it. - **Version skew is the classic failure.** The browser on the grid node is chosen by the grid, not bundled with Playwright, and a node whose browser is far from the version Playwright expects fails in ways that look like flaky tests rather than a configuration error. - **Latency is real.** Every interaction crosses the network to the node, which erodes the speed the migration was partly meant to buy. ## Where it earns its place | Situation | Reasonable? | |---|---| | Ported tests must run while the grid is still the only approved environment | Yes — as a transitional bridge | | A short window where both suites must run against the same browser estate | Yes | | Getting Chromium coverage on a machine that cannot install browsers | Sometimes | | Long-term architecture for a fully ported suite | No | | Getting WebKit or Firefox coverage from the grid | Not possible | The framing that lands is that Playwright's default model — browsers it manages, contexts per test, workers in parallel on the runner itself — is what makes the ported suite fast, and routing through a hub gives that up. The bridge buys time, not capability. ## Diagnosing a bridge that will not connect 1. Confirm the run is actually using the bridge: the variable has to be set in the environment of the process that runs the tests, and only a Chromium project will honour it. 2. Turn on browser-level logging with `DEBUG=pw:browser*` to see the session request and the CDP connection attempt separately — they fail for different reasons. 3. If the session is created but the connection is not, look at whether the node's browser exposes a reachable debugging endpoint through the hub; a hub that proxies WebDriver traffic but not the debugging connection is a common blocker. 4. If the hub rejects the request outright, check `SELENIUM_REMOTE_HEADERS` for the authentication the hub requires, and `SELENIUM_REMOTE_CAPABILITIES` for anything the grid demands before it allocates a node. 5. Compare against a plain local run of the same project. If it passes locally and fails only through the bridge, the fault is in the transport, not the ported test. ## The planning answer Asked about this in a migration interview, say what it is for: the legacy insurance-quote suite runs on a grid the team cannot switch off this quarter, and the variable lets the first ported Chromium tests run there without waiting for new infrastructure. Then say what you would plan around it — that it is experimental, single-engine, slower, and that the migration should retire it along with the grid rather than build on it. Version note: this describes Playwright 1.63, and an experimental feature is exactly the kind that should be re-checked against the release the team pins.
- Why does the bridge not solve cross-browser coverage for a migrating suite?Because it covers Chromium-based browsers only. Firefox and WebKit projects still need browsers Playwright manages itself, locally or in a container image, so a suite that relies on the bridge for everything silently loses the engine coverage the migration was supposed to gain.
- A ported test passes locally but fails only through the bridge. Where do you look first?Split the failure in two with `DEBUG=pw:browser*`: did the hub allocate a session, and did the debugging connection to that browser succeed? Session failures point at authentication or capabilities; connection failures point at the hub not proxying the debugging endpoint, or at browser version skew on the node.
saying these in an interview costs you the question
- Calling the grid bridge a supported long-term deployment model
- Expecting Firefox or WebKit to run through the grid
- Setting it in config rather than the run environment
- Assuming test code must change to target the grid
- Ignoring node browser version skew when tests turn flaky