Summary
We want to use @playwright/cli from a development container while the browser runs in a separate Playwright service container. This is the same setup we already use successfully for E2E tests with @playwright/test and chromium.connect(...).
With @playwright/cli, configuring browser.remoteEndpoint against a Playwright run-server endpoint fails before opening a page.
Use Case
Our devcontainer has a Playwright service:
playwright:
image: mcr.microsoft.com/playwright:v1.60.0-noble
command: npx -y playwright@1.60.0 run-server --port 3456 --host 0.0.0.0
Our application containers can reach it at:
This works with @playwright/test using chromium.connect(...). We would like playwright-cli to work the same way so agents/developers can run browser automation commands without installing or launching a browser in the development image.
Reproduction
Start a Playwright server:
docker run --rm --name playwright-server \
-p 3456:3456 \
mcr.microsoft.com/playwright:v1.60.0-noble \
/bin/sh -c "npx -y playwright@1.60.0 run-server --port 3456 --host 0.0.0.0"
Use .playwright/cli.config.json:
{
"browser": {
"browserName": "chromium",
"isolated": true,
"remoteEndpoint": "ws://localhost:3456/",
"launchOptions": {
"channel": "chrome"
}
}
}
Run:
playwright-cli open https://example.com --config=.playwright/cli.config.json
Actual Behavior
The CLI fails with:
Cannot read properties of undefined (reading 'launch')
With debug output, the inner error is server-side:
TypeError: Cannot read properties of undefined (reading 'launch')
at PlaywrightServer._initLaunchBrowserMode
Expected Behavior
playwright-cli should use browser.browserName from the config when connecting to a Playwright run-server endpoint, and should open the page successfully:
### Page
- Page URL: https://example.com/
- Page Title: Example Domain
Local Validation
We patched the bundled playwright-core locally to pass browserName when connecting to the remote endpoint. With that patch and matching client/server Playwright versions, the CLI successfully opened https://example.com and produced a snapshot.
This appears to be caused by the playwright-core implementation used by @playwright/cli, not by the thin playwright-cli wrapper itself. I will link the corresponding core issue here once filed.
Summary
We want to use
@playwright/clifrom a development container while the browser runs in a separate Playwright service container. This is the same setup we already use successfully for E2E tests with@playwright/testandchromium.connect(...).With
@playwright/cli, configuringbrowser.remoteEndpointagainst a Playwrightrun-serverendpoint fails before opening a page.Use Case
Our devcontainer has a Playwright service:
Our application containers can reach it at:
This works with
@playwright/testusingchromium.connect(...). We would likeplaywright-clito work the same way so agents/developers can run browser automation commands without installing or launching a browser in the development image.Reproduction
Start a Playwright server:
docker run --rm --name playwright-server \ -p 3456:3456 \ mcr.microsoft.com/playwright:v1.60.0-noble \ /bin/sh -c "npx -y playwright@1.60.0 run-server --port 3456 --host 0.0.0.0"Use
.playwright/cli.config.json:{ "browser": { "browserName": "chromium", "isolated": true, "remoteEndpoint": "ws://localhost:3456/", "launchOptions": { "channel": "chrome" } } }Run:
Actual Behavior
The CLI fails with:
With debug output, the inner error is server-side:
Expected Behavior
playwright-clishould usebrowser.browserNamefrom the config when connecting to a Playwrightrun-serverendpoint, and should open the page successfully:Local Validation
We patched the bundled
playwright-corelocally to passbrowserNamewhen connecting to the remote endpoint. With that patch and matching client/server Playwright versions, the CLI successfully openedhttps://example.comand produced a snapshot.This appears to be caused by the
playwright-coreimplementation used by@playwright/cli, not by the thinplaywright-cliwrapper itself. I will link the corresponding core issue here once filed.