rushstack
rushstack copied to clipboard
Playwright Browser Server
Summary
Introducing Playwright Browser Server. A CLI based tool to launch a remote browser provider for Playwright.
This tool enables using headful browsers on the local machine when using Playwright with VS Code remote sessions.
Use cases:
- Running Playwright tests in Codespaces / WSL / VS Code Tunnels workspaces and using local browsers on the local computer
- Running Playwright MCP in VS Code when using remote workspaces
Details
This tool uses a reverse port forwarder concept to tunnel the Playwright WebSocket control messages over VS Code port forwarding.
Flow:
- User has this playwright browser server tool running on the local computer
- User runs a playwright test in a VS Code window connected to a Codespace
- The browser fixture in the Codespace starts a server on a known port (3000). This log message is read by VS Code and it forwards this port.
- The browser server tool is polling this known port to be opened.
- Once a connection is established, it launches the requested browser with the launch options and sets up a forwarding between the Playwright browser and the existing open connection.
- Test can now use the remote browser.
Playwright MCP can also be used through this setup in VS Code remote environments.
How it was tested
Tested end-to-end with the Playwright test and fixture introduced in this change. Tested this on pure local setup as well as on Codespaces
Tested MCP change by prompting agent mode to use Playwright MCP on Codespaces.