Command-line tool

edit

The Meziantou.Framework.WebPlatform.Playwright.Tool .NET tool runs a Playwright server whose browser is this engine, without writing code. Install it:

dotnet tool install --global Meziantou.Framework.WebPlatform.Playwright.Tool

Start a server on port 3000 whose pages can load any URL:

Meziantou.Framework.WebPlatform.Playwright.Tool --port 3000 --allow-network

The server prints its endpoint (Listening on ws://127.0.0.1:3000/) and runs until Ctrl+C. Connect a Playwright client to it with BrowserType.ConnectAsync("ws://127.0.0.1:3000/") in .NET, or browserType.connect() in Node.js, as in Hosting the server. The clients must use the version of Playwright of the server, which the help shows.

Options

OptionDefaultEffect
--host127.0.0.1The address to listen on (0.0.0.0 accepts remote clients)
--port0 (a free port)The port to listen on
--path/The path of the WebSocket endpoint
--allow-networkoffThe pages can load the documents and the resources of any URL
--system-fontsoffThe pages can use the fonts installed on the machine
--browser-namechromiumThe name of the browser reported to the clients (chromium, firefox or webkit)
--allow-any-client-versionoffAccepts the clients of another version of Playwright

The command reference lists them with the help of the tool.

Without --allow-network, the pages only use the content of page.setContent() and the responses of the routes (page.route()). The scripts of the pages run in the process of the server: connect trusted clients only, and load trusted pages only.