To capture an authenticated page without logging in interactively for every run, save the browser context’s storage state after a successful login, restore that state in a new Playwright Java context, verify that the protected page is actually authenticated, and then call Page.screenshot(). Restoring state reuses the session your account already has; it does not bypass the site’s access controls.
Save login state, restore it, and capture the page
Playwright persists authentication at the BrowserContext level. The login flow is site-specific, so complete it through the website’s supported sign-in process and confirm success before writing the state file. The example below shows the API calls and the points where you must supply site-specific login and readiness checks; those steps are deliberately not presented as a universal, tested login recipe.
import com.microsoft.playwright.*;
import java.nio.file.Paths;
public class AuthenticatedScreenshot {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
// First run: sign in through the site's normal supported flow.
BrowserContext loginContext = browser.newContext();
Page loginPage = loginContext.newPage();
loginPage.navigate("https://example.com/login");
// Complete the site's login flow and verify successful sign-in here.
loginContext.storageState(
new BrowserContext.StorageStateOptions()
.setPath(Paths.get("playwright/.auth/user.json")));
loginContext.close();
// Later run: restore the saved state in a fresh isolated context.
BrowserContext context = browser.newContext(
new Browser.NewContextOptions()
.setStorageStatePath(Paths.get("playwright/.auth/user.json")));
Page page = context.newPage();
page.navigate("https://example.com/account");
// Wait for a reliable, site-specific indicator that the account page is ready.
page.screenshot(new Page.ScreenshotOptions()
.setPath(Paths.get("authenticated-page.png")));
context.close();
browser.close();
}
}
}
Replace both example URLs, complete the supported sign-in flow, and add a readiness check tied to the application—for example, a locator unique to the signed-in account view. Navigation completing is not proof that authentication worked: a site may redirect to sign-in or render an unauthenticated page at the requested URL. The example’s placeholder comments must be replaced before it can serve as an end-to-end capture script.
The Java API saves state through BrowserContext.storageState(StorageStateOptions) and restores it through the browser context’s storage-state path option. The screenshot is saved to the given path with Page.screenshot(). See the Playwright Java BrowserContext API, Page API, and authentication guide.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →#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.
Choose the screenshot output you need
Viewport, full page, or a region
By default, a page screenshot captures the visible viewport. Set setFullPage(true) when you need the full scrollable document. For a specific rectangular region, set a screenshot clip rectangle; for one element, use Locator.screenshot(). Full-page images can be substantially taller than viewport captures, so choose based on what the image needs to show.
File, bytes, format, and scale
Set a path to write an image directly to disk, or use the screenshot bytes when you need to post-process the result in memory. Playwright’s screenshot options also support PNG, JPEG, and WebP output, CSS or device scale, animation handling, and locator masks. Scale affects output dimensions; a mask can cover sensitive or variable regions. Choose options deliberately so the saved artifact represents the evidence you intend to preserve. See the Playwright Java screenshots guide and Page API.
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.
Check which browser storage the app uses
Cookies and local storage
Browser context storage state can include cookies and local-storage snapshots. For many applications, that is enough to restore an authenticated session, but the application’s implementation determines what must be present.
IndexedDB, OPFS, and virtual WebAuthn credentials
The Java reference documents options for IndexedDB, the origin private file system (OPFS), and virtual WebAuthn credentials. If the application stores authentication tokens in IndexedDB, enable the IndexedDB snapshot option when saving state. These are versioned capabilities: the Java API marks IndexedDB as added in v1.51, setStorageState in v1.59, virtual credentials in v1.61, and OPFS in v1.63. Confirm your installed Playwright Java version supports any option you plan to use. See the BrowserContext API and Java API version annotations.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #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.
Session storage
The standard storage-state API does not persist sessionStorage. If the app depends on it, Playwright’s authentication guide demonstrates serializing the required values and restoring them with context.addInitScript for the matching domain. This is an application-specific workaround: restore only the values the app needs and test the result. See the Playwright authentication guide.
Protect the saved state and the screenshot
A storage-state file can act like a credential. Playwright warns: “The browser state file may contain sensitive cookies and headers that could be used to impersonate you or your test account.” Keep the file in a restricted local or managed secret location, add the auth directory to .gitignore, and do not commit state files to a repository. Prefer a test account with only the access required. Remove or refresh state when it expires or is revoked; the site and account policy determine its lifetime, and Playwright does not provide a universal expiry interval. See the Playwright authentication guide.
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 the same care to captured images: account pages may expose personal information or secrets. Use a synthetic account where appropriate, and mask or crop sensitive areas before sharing an artifact.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot failed or misleading captures
- The protected URL shows a login page. The state may be missing, expired, revoked, or insufficient for the app’s authentication design. Detect a login redirect or missing account-specific locator, then refresh state through the supported login flow rather than saving a screenshot that looks successful.
- The login succeeds, but the restored context is unauthenticated. Check whether the app relies on IndexedDB or session storage rather than only cookies and local storage. Enable the appropriate version-supported IndexedDB snapshot option if needed; handle session storage separately using the documented, domain-specific initialization approach.
- The screenshot is blank, incomplete, or captures a loading screen. Navigation completion alone does not establish that the application is rendered. Wait for a reliable site-specific readiness indicator before taking the screenshot.
- The saved image omits content below the fold. The default screenshot is the viewport. Enable full-page capture when you need the scrollable document, or capture a specific clip or element when only part of the page is relevant.
- A storage option is unavailable. Verify the Playwright Java version in the project against the API’s version annotations before using newer storage-state features.
- The artifact exposes data that should not be shared. Use a lower-privilege test account, mask or crop the relevant region, or keep the screenshot private.
Or skip the browser setup
For a screenshot request that does not require your own authenticated browser session, ScreenshotNeo offers a one-call API:
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 & 11Best 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.
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 the API details. ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those cleanup steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free 1,000 screenshots per month, with no card required.
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.

