Get started with Playwright for .NET
mainPlaywright for .NET is the official .NET port of Playwright, designed for cross-browser web automation across Chromium, Firefox, and WebKit. It provides a single API to automate modern web applications reliably and fast.
To use Playwright, you can install the Microsoft.Playwright NuGet package. The library supports Linux, macOS, and Windows.
using System.Threading.Tasks;
using Microsoft.Playwright;
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new() { Headless = false });
var page = await browser.NewPageAsync();
await page.GotoAsync("https://playwright.dev/dotnet");
await page.ScreenshotAsync(new() { Path = "screenshot.png" });