-
Notifications
You must be signed in to change notification settings - Fork 293
Description
π Feature Request
There already has been some discussion about this here: #1850 (comment)
We would like to be able to connect to a remote playwright instance without needing the node runtime.
This is currently not possible, because Playwright.CreateAsync() already requires node and the existing BrowserType.ConnectAsync also uses the node process under the hood.
This could be solved with a new API, similiar as was proposed in the linked comment.
public class Playwright
{
static Task<IBrowser> ConnectAsync(string wsEndpoint, string browserName, BrowserTypeConnectOptions? options = null, CancellationToken cancellationToken = default);
}
This would use the managed ClientWebSocket under the hood to avoid the node process.
I already have working prototype here: https://github.com/mus65/playwright-dotnet/tree/connectasync
Would something like this be accepted? If so, I would add some tests and open a PR.
fyi @djhayman
Example
await using var browser = await Playwright.ConnectAsync("ws://localhost:3000/", "chromium");
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await page.ScreenshotAsync(new PageScreenshotOptions { Path = "screenshot.png" });
Motivation
It would allow playwright to be used in environments where node either cannot be used or should be avoided due to security (node CVEs) and/or resource considerations (container image size).