a small and simple helper library to manually download browsers for playwright usage.
this library is under development - the API is subject to change.
nor0x.Playwright.BrowserDownloader allows to manually download browsers for Playwright usage, in a managed way from .NET. It allows injection of a custom HttpClient
and reports download progress via IProgress
. It ships with the browsers.json
file from Playwright but can also handle a custom version file.
var downloader = new BrowserDownloader(new MyCustomHttpClient());
await downloader.DownloadBrowserAsync("chromium", "mac12", new Progress<double>(progressCallback));
void progressCallback(double p)
{
Console.WriteLine("download progress: " + p);
}
specific versions can be set by passing the version string to the DownloadBrowserAsync
method. If there is already an IPlaywright
object available, the executable path for a browser engine can be set directly.
using var playwright = await Playwright.CreateAsync();
var downloader = new BrowserDownloader();
await downloader.DownloadBrowserAsync("firefox", "win64", downloadPath: browserPath, executablePath: playwright.Firefox.ExecutablePath);
https://johnnys.news/2023/07/nor0x-Playwright-BrowserDownloader
happy coding and mtfbwya ✨