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
World desk5 min

How to Capture a Webpage Screenshot with Playwright in .NET

Use Playwright .NET's ScreenshotAsync to save a webpage, full page, or element capture. Learn browser installation, image options, and fixes for common issues.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Playwright for .NET, navigate a Page to the webpage and call ScreenshotAsync. By default, it captures the visible viewport; set FullPage = true to capture the full scrollable page. Install the Playwright browser binaries that match your package version before running the code.

Capture a webpage and save the screenshot

This minimal C# program launches Chromium, opens a page, navigates to a URL, and writes a PNG screenshot to screenshot.png in the process’s current working directory:

As an Amazon Associate I earn from qualifying purchases.

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 key call is Page.ScreenshotAsync. It runs after navigation, and the Path option saves the result to disk. The file extension determines the image type unless you explicitly set Type. Playwright documents PNG, JPEG, and WebP; WebP support depends on the installed Playwright version, with support identified in the .NET 1.62 release notes. See the Playwright .NET screenshot guide and release notes for current details.

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

Install the matching browser binaries

Playwright requires browser binaries compatible with the Playwright version in your project. After adding or updating the package, run the generated CLI script from the project directory. The documented PowerShell command is:

#1 Best Overall
Dell Optiplex 3060 Desktop Computer | Intel i5-8500 (3.2) | 32GB DDR4 RAM | 1TB SSD Solid State | Built in WiFi | Bluetooth | Windows 11 Professional | Home or Office PC (Renewed)
  • [INTEL POWERED CONTENT] - Built with a 8th Generation Hexa-Core Intel i5 and 32GB of DDR4 RAM; Modern, Windows 11 ready, with 4K support, Executive multitasking, media streaming and smooth, multi-tab web browsing; Perfect as an all-purpose multimedia computer; built for content creators; Plenty of RAM and Mass storage for photo and video editing powered by Intel HD 630
  • [LATEST WIRELESS TECH] - This Dell Desktop Computer easily connects to the internet through the Built In WiFi / Bluetooth
  • [SOLID STATE STORAGE] - This Dell Computer setup comes with an ultra-fast 1TB Solid State Drive (SSD); Setup as the primary boot device; Boot and load programs with lightning speed ; Additional expansion available
  • [BUY & OWN WITH CONFIDENCE] - From the world's largest Microsoft Authorized Refurbisher; Quality Guarantee and Free Tech Support; Award-winning Customer Service; | Support Sustainable Business
  • [MODERN HI-SPEED PORTS] - USB 3.0 (x4) | USB 2.0 (x4) | DisplayPort (x1) | HDMI Port (x1) | Audio Combo Jack (x1) | Audio Out (x1) | RJ-45 Ethernet (x1) | Internal SATA (x3)
pwsh bin/Debug/netX/playwright.ps1 install

Replace netX with your project’s target framework directory. To install a particular supported browser, provide its name to the install script as described in the browser installation documentation. If you update Playwright, rerun installation when needed; the supported browser versions track Playwright releases.

Choose what to capture

Visible viewport

The default is the currently visible viewport. Leave FullPage unset or set it to false when the screenshot should match the browser’s current viewport rather than the entire document.

Rank #2
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
  • Model: Dell OptiPlex 7050 Small Form Factor (SFF)
  • Processor: Intel Core i7-7700 3.60 GHz
  • Memory: 32GB DDR4 Ram
  • Storage: 1TB Solid State Drive (SSD) Fast Boot + Storage
  • Operating System: Windows 11 Pro (64-bit)

Full scrollable page

Set FullPage = true to capture the entire scrollable page as one tall image:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.ScreenshotAsync(new()
{
    Path = "full-page.png",
    FullPage = true
});

One element

Use a locator’s ScreenshotAsync method to save the matched element’s bounds. Playwright waits for actionability and scrolls the element into view:

Rank #3
Sale
HP All-in-OneDesktop Computer, 16GB DDR5 RAM, Intel Quad-Cores, 128GB SSD, WiFi6, Keyboard & Mouse, Windows 11
  • IMMERSIVE 24 INCH DISPLAY: Experience stunning clarity on a Full HD IPS screen with ultra-thin bezels, offering a 90% screen-to-body ratio that makes everything from spreadsheets to streaming come alive with vibrant colors and crisp details.
  • POWERFUL INTEL PROCESSING: Tackle demanding tasks with ease thanks to the Intel processor and 16GB of high-speed memory, delivering smooth performance whether you're multitasking between applications or running productivity software.
  • GENEROUS STORAGE: Store all your important files, photos, and programs with blazing-fast solid state drive technology that ensures quick boot times, rapid file access, and plenty of space for your digital life.
  • ENHANCED PRIVACY AND COLLABORATION: Work confidently with the pop-up privacy camera that tucks away when not in use, plus dual microphones with noise reduction for crystal-clear video calls that keep you connected professionally.
  • ECO-CONSCIOUS DESIGN: Feel good about your purchase with an EPEAT Gold registered and ENERGY STAR certified computer that combines premium performance with responsible environmental manufacturing practices.
await page.Locator(".header").ScreenshotAsync(new()
{
    Path = "header.png"
});

If another element covers the target, the screenshot does not reveal the pixels underneath it. For an element inside a scrollable container, the capture includes only the container’s currently scrolled content. See the Locator screenshot API.

Rectangular clipped region

For a defined region rather than a locator, use the page screenshot option’s Clip coordinates and dimensions. This is useful when you know the rectangle to save and do not need to target an element.

Rank #4
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
  • This Certified Refurbished product is tested and certified to look and work like new. The refurbishing process includes functionality testing, basic cleaning, inspection, and repackaging. The product ships with all relevant accessories, a minimum 90-day warranty, and may arrive in a generic box. Only select sellers who maintain a high-performance bar may offer Certified Refurbished products on Amazon.com.
  • Dell Optiplex 3050 SFF Desktop computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD
  • Includes: USB Keyboard & Mouse, USB WiFi adapter, Microsoft office 30 days free trail.
  • Port: Front: USB 3.0(2), USB 2.0(2); Rear: DP, HDMI, USB 3.0(2), USB 2.0(2), RJ-45.
  • Support 4K (3840x2160) Dual display, makes it easy to connect two monitors at the same time, and you can expand working Windows, mirror content, or expand a single window across multiple monitors.

Choose a file or image bytes

Providing Path saves the screenshot to a file. Without it, ScreenshotAsync returns a byte[], which you can pass to another method or an image-diff process:

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.
byte[] screenshot = await page.ScreenshotAsync();

Use a format extension that matches your intended image type when saving to a path. Set the screenshot Type option explicitly if you need to select a format independently of the path.

Best Value
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
  • Connectivity: Includes WiFi, Bluetooth, and LAN for wireless and wired connections
  • Memory: Features 16GB DDR4 RAM for smooth multitasking and performance
  • Storage: Combines 500GB SSD and 1TB HDD for ample storage space
  • Graphics: Integrated Intel UHD Graphics 630 for crisp visuals and video playback
  • Design: Sleek desktop tower with black color and slim profile for modern look
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Tune image output and repeatability

  • JPEG quality: The documented range is 0–100 and the default is 80. Quality does not apply to PNG. WebP quality 100 is lossless; lower values are lossy.
  • Scale: Css produces one output pixel per CSS pixel. Device uses device pixels and is the API default, so high-DPI settings may produce larger images.
  • Transparent background: OmitBackground can remove the default white background, but does not apply to JPEG.
  • Animations: Animations = Disabled fast-forwards finite animations and cancels infinite ones for the capture before allowing them to continue.
  • Injected styling and masks: Use Style to inject CSS during capture and Mask to cover selected locator regions.
  • Caret: Screenshot options also provide caret control, which can help avoid a blinking text cursor in captured output.
  • Timeout: The documented screenshot timeout defaults to 30,000 ms. Setting it to 0 disables the timeout; the default can also be changed at page or context level.

These settings and their current signatures are documented in the Page screenshot API.

Manage page and browser lifetimes

Browser.NewPageAsync() is convenient for a short standalone example. For production code and test frameworks, the Browser API recommends explicitly creating a BrowserContext and a page so their lifetimes are controlled. Close or dispose the context and browser as appropriate for your application’s structure. The Browser API describes context creation.

Troubleshoot common screenshot problems

  • The browser fails to launch because an executable is missing: Install the browser binaries for the Playwright version in the project using its generated CLI script. After a package update, install again if the expected browser version has changed.
  • The image shows only the first screen: This is the default viewport behavior. Set FullPage = true for the full scrollable page.
  • The image is saved somewhere unexpected: Relative screenshot paths resolve from the current working directory. Use an absolute path or check the working directory of the process.
  • A locator screenshot omits part of a long scrollable element: Locator capture includes only the scrollable content currently visible inside its container. Scroll the container to the desired position before capture, or use a different capture approach.
  • A WebP screenshot fails: Check the project’s installed Playwright version; documented .NET WebP support is release-dependent and appears in the 1.62 release notes.
  • The screenshot call times out: The default screenshot timeout is 30 seconds. Confirm the page and target locator are ready, and adjust the timeout at the screenshot, page, or context level if the capture legitimately needs longer.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server for developers. It accepts a URL in one GET request and returns an image or PDF, without requiring you to install browser binaries for this capture. Its clean-shot steps accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response reports the page verdict and billing status. Its MCP server gives Claude, Cursor, and other MCP clients the tools take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

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

For example, this saves a WebP shot of Stripe:

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

See the ScreenshotNeo API documentation for setup and options, including full-page and element capture. Learn more at ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Can Playwright .NET use Firefox or WebKit for screenshots?

Yes. Chromium is used in the example, but Playwright can launch supported browser engines such as Firefox and WebKit.

Can I capture a screenshot as bytes without creating a file?

Yes. Call ScreenshotAsync without setting Path; it returns a byte[].

Quick Recap

Bestseller No. 2
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
Dell Optiplex 7050 SFF Desktop PC Intel i7-7700 4-Cores 3.60GHz 32GB DDR4 1TB SSD WiFi BT HDMI Duel Monitor Support Windows 11 Pro Excellent Condition(Renewed)
Model: Dell OptiPlex 7050 Small Form Factor (SFF); Processor: Intel Core i7-7700 3.60 GHz; Memory: 32GB DDR4 Ram
$384.00
Bestseller No. 4
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
Dell Optiplex 3050 SFF Desktop Computer PC, Intel Quad Core i5-6500 up to 3.6GHz, 16GB DDR4, 256GB SSD, WiFi, 4K Support, DP, HDMI, Windows 11 Pro 64 Bit (Renewed)
Includes: USB Keyboard & Mouse, USB WiFi adapter, Microsoft office 30 days free trail.; Port: Front: USB 3.0(2), USB 2.0(2); Rear: DP, HDMI, USB 3.0(2), USB 2.0(2), RJ-45.
$189.99
Bestseller No. 5
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
Dell Windows 11 Desktop Computer OptiPlex 5060 | Intel Core i5-8500 Six Core (4.3GHz Turbo) | 16GB DDR4 RAM | 500GB SSD Solid State + 1TB HDD | WiFi + Bluetooth | Home or Office PC (Renewed)
Connectivity: Includes WiFi, Bluetooth, and LAN for wireless and wired connections; Memory: Features 16GB DDR4 RAM for smooth multitasking and performance
$255.00

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.

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

Leave a Reply

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

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.