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.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchInstall 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
- [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
- 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:
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
- 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
- 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.
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
- 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
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:
Cssproduces one output pixel per CSS pixel.Deviceuses device pixels and is the API default, so high-DPI settings may produce larger images. - Transparent background:
OmitBackgroundcan remove the default white background, but does not apply to JPEG. - Animations:
Animations = Disabledfast-forwards finite animations and cancels infinite ones for the capture before allowing them to continue. - Injected styling and masks: Use
Styleto inject CSS during capture andMaskto 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
0disables 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 = truefor 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.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →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
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.




