Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
browser automation

How to Capture Website Screenshots from URLs in C#

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Microsoft Playwright for .NET to open a URL in a real browser and save a screenshot: call GotoAsync, then ScreenshotAsync. By default, the image covers the visible viewport; set FullPage = true for the full scrollable page. Playwright also supports element screenshots and image bytes for cases where you do not want a whole-page file.

Capture a website screenshot from a URL with Playwright for .NET

The essential workflow is to create Playwright, launch a browser, create a page, navigate to the URL, and save a screenshot. This example writes a PNG of the current viewport to screenshot.png:

using Microsoft.Playwright;

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GotoAsync("https://example.com");
await page.ScreenshotAsync(new() { Path = "screenshot.png" });

The Playwright .NET API documents this pattern, including browser launch, navigation, and screenshot output. See the Page API reference and the Playwright .NET project.

The code assumes a .NET project with the Microsoft.Playwright package and the matching Playwright browser installed. A common setup is to add the package, then install its browser binaries using the Playwright installation command documented for your project and environment. Browser binaries are separate from the package, so installing the NuGet dependency alone may not be enough to launch Chromium.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a browser engine

Playwright supports Chromium, Firefox, and WebKit. The sample launches Chromium; choose another engine when the target site or the rendering behavior you need calls for it:

await using var browser = await playwright.Firefox.LaunchAsync();

Use playwright.Webkit.LaunchAsync() to launch WebKit. Keep the browser engine consistent when comparing screenshots: different engines can render fonts, layout, and controls differently.

Choose the screenshot scope and output

Screenshot behavior is configurable. Pick the smallest output that serves the task, then set the capture options explicitly where repeatability or size matters.

Need Playwright .NET approach Result
Visible viewport page.ScreenshotAsync(new() { Path = "shot.png" }) Captures the currently visible page area by default.
Entire scrollable page page.ScreenshotAsync(new() { Path = "full.png", FullPage = true }) Produces a tall image of the full page.
One element page.Locator(".header").ScreenshotAsync(new() { Path = "header.png" }) Captures the selected element rather than the whole viewport.
Image bytes var bytes = await page.ScreenshotAsync(); Returns image data in memory for storage, post-processing, or transport.

Full-page capture can create very large images on long pages. For a component or report, a locator screenshot or clipped region may be a better fit than a tall full-page image.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Format, quality, and scaling

The API supports PNG, JPEG, and WebP screenshot types. JPEG quality is configurable; the API reference gives a default quality of 80 for JPEG and 100 for WebP. Confirm WebP availability against the version of Playwright installed: version 1.62 release notes add WebP support for Page.ScreenshotAsync() and Locator.ScreenshotAsync(). Check Playwright release notes before depending on a version-specific format.

The Scale option controls whether output is based on CSS pixels or device pixels. Device-pixel output may be larger, particularly at high device scale factors. JPEG is useful when smaller lossy files are acceptable; PNG is lossless; WebP support depends on the installed Playwright version.

Clipping, stylesheets, and animations

Screenshot options include a clip rectangle for capturing a region, a stylesheet option for applying capture-specific CSS, and animation controls. Disabling animations can make repeated captures more consistent when a page contains transitions. These options affect the image, not the page’s underlying content; validate the result if exact dimensions or visual matching are important.

Wait for the page you actually want to capture

GotoAsync navigates to a URL, but there is no single readiness rule that suits every site. Pages may render essential content after initial navigation through client-side code, images, or other network requests. Choose an appropriate navigation or page-specific wait strategy, then capture. For a known element, waiting for its locator to become visible is more targeted than sleeping for an arbitrary duration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A fixed delay can be useful for a page with a known timed transition, but it can waste time on fast loads and still be too short on slow ones. Likewise, waiting for network activity to stop may be unsuitable for sites with long-lived requests. The right condition depends on what must be visible in the output.

Use the screenshot in memory or capture one element

When another part of the application needs the image, omit Path and use the returned byte array:

byte[] image = await page.ScreenshotAsync(new() { FullPage = true });
await File.WriteAllBytesAsync("full-page.png", image);

This still writes a file in the example, but the bytes can instead be sent to object storage, attached to a response, or passed to an image-processing step. For a focused capture, target a locator:

await page.Locator("main article").ScreenshotAsync(new()
{
    Path = "article.png"
});

Use a selector that identifies the intended element uniquely. If the element is absent or not visible, the locator screenshot will not produce the intended result; wait for the element and verify the selector against the rendered page.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Alternative: PuppeteerSharp

PuppeteerSharp provides another documented C# route: fetch a browser with BrowserFetcher, launch it headlessly, open a page, navigate to a URL, and save a screenshot. Its package example is the appropriate starting point for that workflow. See the PuppeteerSharp package example.

The documented examples establish that both libraries can automate browser-based screenshots; they do not establish a universal performance or feature winner. Compare the engine and browser versions you require, screenshot formats and scopes, browser installation and update workflow, operating-system targets, and deployment constraints before selecting one.

Or skip the browser setup

If you need a screenshot from code without installing and managing browser binaries, ScreenshotNeo accepts a URL in one GET request and returns an image or PDF. The following cURL example saves a WebP image:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots per month with no card, and paid plans start at $5 for 3,000. Learn about ScreenshotNeo, then sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting common capture problems

  • Browser launch fails: Check that the Playwright package is installed and that its browser binaries are installed for the project and runtime environment. A package reference by itself does not supply every browser executable.
  • The image is blank or missing content: The page may need more time or a specific element may not yet be visible. Wait for the content your screenshot depends on, and check that navigation completed to the expected URL.
  • The screenshot is only the top portion: Viewport capture is the default. Set FullPage = true when you need the full scrollable page.
  • The image is unexpectedly large: Check whether full-page capture or device-pixel scaling is enabled. Use viewport or element capture, or CSS-pixel scaling, if that matches the requirement.
  • A selected element cannot be captured: Confirm the CSS selector matches an element on the rendered page and wait until that locator is visible before taking its screenshot.
  • Capture takes too long or times out: Screenshot capture has a documented timeout option; the API reference describes a 30-second default. Slow pages and unusually large captures may need a considered timeout adjustment, but increasing it does not fix a page that never reaches the desired state.
  • WebP is not available: Verify the installed Playwright version. WebP support for page and locator screenshot calls is identified in the 1.62 release notes; use PNG or JPEG if the runtime version does not support the needed output.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and cost considerations

A local Playwright capture gives the application control over browser choice, page timing, output scope, and image handling, but the application also needs to run and maintain the browser environment. Browser downloads, page rendering, network conditions, and large full-page images all contribute to operational work and latency. Reusing a browser process for multiple pages may avoid repeated launches in a longer-running application, but lifecycle management and isolation then become application responsibilities.

Do not treat a successful navigation call as proof that a screenshot is complete: define what “ready” means for the target site, and handle navigation, element, and screenshot timeouts as distinct failure cases. For production jobs, record the URL, selected engine, wait condition, and failure stage so intermittent site or network issues can be diagnosed. The Playwright API exposes screenshot timeout configuration; it does not make arbitrary websites deterministic.

Frequently asked questions

Can I capture a screenshot without saving it to disk?

Yes. Call ScreenshotAsync() without a path to get a byte array, then store or process those bytes as needed.

Can I capture only part of a page?

Yes. Use a locator screenshot for a page element or the screenshot clip option for a specified region.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does Playwright support WebKit as well as Chromium?

Yes. Playwright names Chromium, Firefox, and WebKit as supported browser engines; launch the engine that fits the rendering behavior you need.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.