Puppeteer Sharp

Drive the browser from C#.

A .NET port of the Node.js Puppeteer API. Launch Chrome or Firefox, open a page, and click, type, screenshot, or print a PDF.

dotnet add package PuppeteerSharp

The package targets netstandard2.0, net8.0, and net10.0.PuppeteerSharp on NuGet.

C#Quick startDocs quick start
using var browser = await Puppeteer.LaunchAsync(
    new LaunchOptions { Headless = true });
var page = await browser.NewPageAsync();
await page.GoToAsync("https://example.com");
await page.ScreenshotAsync("screenshot.png");
LaunchOptions.Browser defaults to Chrome

Package

PuppeteerSharp

NuGet package id

Targets

netstandard2.0

Plus net8.0 and net10.0

Browsers

Chrome

And Firefox, headless or headful

License

MIT

Free for commercial use

Why Puppeteer Sharp

The Puppeteer API, on the runtimes you already ship.

Navigation, input, network interception, screenshots, and PDFs. Headless or headful, on Windows, macOS, and Linux.

  • Chrome and Firefox

    Launch a browser, open a page, and drive navigation, input, and network interception. Headless and headful both work.

    Browser automation
  • Screenshots and PDFs

    ScreenshotAsync writes a file. Full-page capture, custom viewports, and clipping are in the screenshot guide. PdfAsync prints the page.

    Take a screenshot
  • Locators that wait

    Page.Locator re-finds the element on every action and retries until it is visible, enabled, and in view.

    Locators guide
  • CDP and WebDriver BiDi

    Chrome DevTools Protocol and WebDriver BiDi are both first-class. Pick the protocol that fits the browser.

    Dual protocol

Get started

From an empty project to a screenshot, in three steps.

Install the package, open a page, then screenshot it or click with a locator. Each step links to the page that has the rest.

Read the docs
  1. Install the package

    Add PuppeteerSharp. It targets netstandard2.0, net8.0, and net10.0.

    dotnet add package PuppeteerSharp
    Quick start
  2. Open a page and save a screenshot

    LaunchAsync starts Chrome. GoToAsync loads the URL. ScreenshotAsync writes the file.

    await page.GoToAsync("https://example.com");
    await page.ScreenshotAsync("screenshot.png");
    Screenshot guide
  3. Click with a locator

    A locator waits until the element is enabled and in the viewport, then clicks it.

    await page.Locator("button.submit")
        .SetWaitForEnabled(true)
        .SetEnsureElementIsInTheViewport(true)
        .ClickAsync();
    Locators guide