Use Playwright’s Python page.screenshot() method after navigating to a page. Save the result to a file with path="screenshot.png"; use full_page=True for the full scrollable page, or call screenshot() on a locator to capture one element. Playwright supports synchronous and asynchronous Python APIs, and screenshots can be saved as PNG, JPEG, or WebP.
Take a basic screenshot with synchronous Playwright
This example launches Chromium, opens a page, navigates to a URL, saves the current viewport as a PNG, and closes the browser:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.goto("https://example.com")
page.screenshot(path="screenshot.png")
browser.close()
The path tells Playwright where to write the image. Here, the .png extension selects PNG output. The screenshot is of the page’s current viewport, not automatically the entire document.
Use a reliable navigation point
The example uses page.goto() before capture, so the screenshot happens after navigation returns. If the page’s meaningful content appears later—for example, after client-side rendering—make sure the page has reached the state you intend to capture before calling screenshot(). Otherwise, a technically successful capture may show a loading state or incomplete content. Avoid assuming that one screenshot call itself waits for every site-specific operation to finish.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Use the asynchronous Python API
In an async program, use Playwright’s async API and await browser, page, navigation, screenshot, and close operations:
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto("https://example.com")
await page.screenshot(path="screenshot.png")
await browser.close()
asyncio.run(main())
Choose the sync or async form to fit the surrounding application. The screenshot options described below apply to the same basic capture operation; with the async API, await the screenshot call.
Capture the full page instead of the viewport
Set full_page=True to capture the full scrollable page rather than only the visible viewport:
page.screenshot(path="full-page.png", full_page=True)
In async code, write await page.screenshot(path="full-page.png", full_page=True). This is useful for long articles, landing pages, and page-level visual records where below-the-fold content matters. A full-page image can be substantially taller than a viewport capture; use it when the full document is the intended artifact, not as a substitute for a viewport screenshot when you need to test a specific screen size.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Capture a single element
Call screenshot() on a locator to save the matching element rather than the whole page:
page.locator(".header").screenshot(path="header.png")
page.get_by_role("link", name="Documentation").screenshot(path="documentation-link.png")
The Locator API performs actionability checks and scrolls the element into view. This is often more robust than calculating a crop by hand when the target is a real page element.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
What locator screenshots include
- If another element covers part of the target, the covered portion is not actually visible in the screenshot.
- For a scrollable container, the screenshot captures only the content currently scrolled into view; it does not automatically reveal all content inside that container.
- Use a locator that identifies the intended element unambiguously. If the page has multiple matches, choose a more specific locator or role/name combination.
Choose PNG, JPEG, or WebP
When you provide a path, Playwright infers the image type from the file extension. The documented formats are PNG, JPEG, and WebP. If you omit both an explicit type and a path, PNG is the default format for the returned screenshot bytes.
| Format | How to request it | Useful distinction |
|---|---|---|
| PNG | path="shot.png", or omit the type when capturing to bytes |
Default when no other type is specified. |
| JPEG | path="shot.jpeg" or set the screenshot type to "jpeg" |
JPEG quality is from 0 to 100; the default is 80. |
| WebP | path="shot.webp" or set the screenshot type to "webp" |
At quality 100, WebP is lossless; lower quality values are lossy. WebP screenshot support is documented in Playwright Python 1.62. |
Pick the format based on the artifact’s use: file extension selects the output when using a path, while an explicit type is useful when you want the format independent of the filename. For JPEG or WebP, set quality when you need a particular compression setting. Do not apply a JPEG-style quality assumption to PNG.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Return image bytes instead of writing a file
Omit path to have page.screenshot() return image bytes. This is useful when you want to pass the capture directly to another component rather than save a local file:
image_bytes = page.screenshot()
# For example, write the bytes later:
with open("screenshot.png", "wb") as image_file:
image_file.write(image_bytes)
For async code, use image_bytes = await page.screenshot(). The returned bytes can also be encoded as base64 or passed to an image-processing tool. If you do write those bytes to disk, choose a filename extension that matches the output format.
Make captures more repeatable
Dynamic content can make otherwise identical captures differ. Playwright’s screenshot options let you control several common sources of variation.
Disable animations
Set animations="disabled" to suppress CSS animations and transitions for the capture. Finite animations are fast-forwarded and infinite animations are canceled for the screenshot. This helps when a visual test should compare a stable state rather than a moving effect.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
page.screenshot(path="stable.png", animations="disabled")
Mask changing or sensitive regions
Pass locators in mask to cover regions that vary between runs or should not appear in the artifact. The default mask overlay is pink (#FF00FF); set mask_color to choose another color.
page.screenshot(
path="masked.png",
mask=[page.locator(".timestamp"), page.locator(".user-avatar")],
mask_color="#222222",
)
Use a mask deliberately: it hides the selected areas in the screenshot, so it is appropriate for intentionally excluded content, not for concealing a failed or incorrect page state.
Capture a rectangle with clip
Use clip for a rectangular area defined by its position and dimensions:
page.screenshot(
path="region.png",
clip={"x": 20, "y": 40, "width": 640, "height": 360},
)
This is useful when the area of interest is a fixed region rather than a semantic element. Coordinates and dimensions are part of the capture definition, so revisit them if the layout changes.
Control pixel scale
The default scale="device" uses device scale and can produce larger images on high-DPI displays. Set scale="css" when you want one output pixel per CSS pixel:
page.screenshot(path="css-scale.png", scale="css")
Use the scale that matches the comparison you need. A device-scale image and a CSS-scale image can have different pixel dimensions even when they represent the same page layout.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Apply screenshot-only CSS
The style option injects CSS for the screenshot. The API reference describes that stylesheet as piercing Shadow DOM and applying to inner frames as well. This can be useful to hide or normalize elements only for the capture without changing the page’s normal stylesheet:
page.screenshot(
path="normalized.png",
style=".timestamp { visibility: hidden !important; }",
)
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common problems and fixes
The screenshot is blank or shows a loading state
The capture may have happened before the page’s useful content appeared. Check that navigation succeeded and that any site-specific rendering or content-loading step has completed before taking the screenshot. Capture again after the state you need is present; do not treat a returned image file as proof that the page rendered correctly.
Recommended Free Tools
The screenshot contains only the visible portion of a long page
A default page screenshot captures the viewport. Set full_page=True if the goal is the entire scrollable page. If you are capturing a locator inside a scrollable container, remember that only the currently scrolled content is captured.
The target element is missing or partly hidden
Confirm that the locator matches the element you want. Locator screenshots scroll the target into view and perform actionability checks, but a different page element covering it still hides the covered portion in the image. If the target lives in a scrollable container, scroll that container to the content you need before capturing.
The image type is unexpected
Check the filename extension when using path; Playwright infers the output format from it. If you are capturing bytes and need a particular format, specify the screenshot type instead of relying on a filename.
The output is larger than expected
On high-DPI displays, the default device scale can create larger images. Try scale="css" if one output pixel per CSS pixel is the intended result. For JPEG or WebP, a lower quality setting can reduce image size at the cost of lossy compression; WebP quality 100 is lossless.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Or skip the browser setup
If you need a website screenshot without writing and maintaining a browser-capture script, ScreenshotNeo provides a screenshot API and MCP server for developers. A GET request can return an image or PDF. The API accepts a URL and can return PNG, JPEG, WebP, or PDF; its options include full-page capture, element selection, viewport and device settings, and screenshot styling. See the ScreenshotNeo API documentation for parameters and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
Cookie banners and consent prompts, newsletter popups, and chat widgets are removed before the shot; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, with verdict and billing information in response headers. AI agents can use its MCP server tools, including 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.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month without a card.
Cost, output, and workflow considerations
For a local Playwright workflow, the screenshot call writes to a path or returns bytes, so your script controls where the artifact goes and what happens next. Select full-page or viewport scope intentionally, use a locator for element-level captures, and choose an output format that fits downstream use. If visual comparisons need consistency, specify animation, masking, scale, clipping, and styling options rather than relying on whatever state happens to be visible.
Outdated 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 matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11No performance benchmark is established here, so do not assume a particular capture time or throughput. Actual time depends on loading and rendering the page as well as the capture itself. For automation, decide how your surrounding program will handle navigation failures and incomplete page states; a screenshot file alone does not distinguish a good page from a failed or blank one.
Which Playwright screenshot method should you use?
- Use
page.screenshot(path=...)for the current viewport saved to a file. - Add
full_page=Truewhen the entire scrollable page is required. - Use
locator.screenshot(path=...)when only one element is needed. - Omit
pathwhen you need the image bytes in Python rather than an immediate file. - Set format, quality, animation, masking, clipping, scale, or injected style when those properties matter to the output.
Frequently Asked Questions
Does full_page=True apply to a locator screenshot?
It is the page screenshot option for capturing the full scrollable page. A locator screenshot targets the matching element and does not reveal all content inside a scrollable container.
Can I get a screenshot without saving it to a file?
Yes. Omit path; the screenshot call returns image bytes.
Which Playwright Python version documents WebP screenshot support?
Playwright Python 1.62 documents WebP screenshot support.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteQuick 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.

