To screenshot a logged-in page with Playwright, add the authentication cookie to the BrowserContext that will own the page, then navigate and capture it. Call await context.addCookies([...]) before page.goto(); cookies added to a context are installed in all pages in that context.
Seed the context before navigating
This TypeScript example uses a cookie supplied by an authorized test account. Replace the illustrative cookie name and URL scope with the values that match your application. Set SESSION_COOKIE in your environment before running the script.
As an Amazon Associate I earn from qualifying purchases.
import { chromium } from '@playwright/test';
const sessionCookie = process.env.SESSION_COOKIE;
if (!sessionCookie) throw new Error('Set SESSION_COOKIE before running this script');
const browser = await chromium.launch();
try {
const context = await browser.newContext();
await context.addCookies([
{
name: 'session',
value: sessionCookie,
url: 'https://example.com',
httpOnly: true,
secure: true,
sameSite: 'Lax',
},
]);
const page = await context.newPage();
await page.goto('https://example.com/account');
await page.screenshot({ path: 'authenticated-page.png', fullPage: true });
await context.close();
} finally {
await browser.close();
}
- Launch the browser and create the context that will be used for the screenshot.
- Await
context.addCookies()with the valid cookie before navigating. - Create a page in that context, navigate to the protected URL, and capture the page.
- Close the context and browser when the script is finished.
Playwright requires each cookie to specify either url or both domain and path. The BrowserContext API also supports expires (Unix time in seconds), httpOnly, secure, sameSite, and partitionKey. Use values consistent with the application’s actual cookie configuration; see the BrowserContext API.
Recommended Free Tools
Choose the right cookie scope and attributes
Use a URL scope for a single site
url is a convenient way to associate a cookie with a site. Ensure it corresponds to the host and scheme where the cookie should be sent. In the example, the cookie is scoped to https://example.com, and the target page uses that host.
#1 Best Overall
- Compatible with Nintendo Switch 2’s new GameChat mode
- Auto-Light Balance: RightLight boosts brightness by up to 50%, reducing shadows so you look your best—compared to previous-generation Logitech webcams (1)
- Privacy with a Slide: The integrated webcam cover makes it easy to get total, reliable privacy when you're not on a video call
- Built-In Mic: The built-in microphone lets others hear you clearly during video calls
- Easy Plug-And-Play: The Brio 101 works with most video calling platforms, including Microsoft Teams, Zoom and Google Meet—no hassle; it just works
Use domain and path together when needed
If you specify domain, you must also specify path. A leading dot in the domain includes subdomains, according to the API reference. Do not broaden a cookie’s scope unless the application requires it.
Match the application’s security settings
Cookie flags are not interchangeable defaults. For example, a cookie marked Secure is intended for secure connections. Use the real cookie’s settings and current validity rather than copying the illustrative attributes blindly. An expired or incorrectly scoped cookie may be accepted by the browser context but fail to authenticate the page.
Rank #2
- Compatible with Nintendo Switch 2’s new GameChat mode
- Crisp HD 720p/30 fps video calls with diagonal 55° field of view and auto light correction. Compatible with popular platforms including Skype and Zoom.
- The built-in noise-reducing mic makes sure your voice comes across clearly up to 1.5 meters away, even if you’re in busy surroundings.
- C270’s RightLight 2 feature adjusts to lighting conditions, producing brighter, contrasted images to help you look good in all your conference calls.
- The adjustable universal clip lets you attach the camera securely to your screen or laptop, or fold the clip and set the webcam on a shelf. You’re always ready for your next video call.
Use a saved authentication state for repeated tests
Direct cookie insertion is useful when you already have a valid cookie and need to authenticate one context. For repeated runs, Playwright’s authentication guide recommends authenticating once in a setup project, saving storageState, and configuring test projects to reuse it. Saved state can include cookies, local storage, IndexedDB, and passkey-based authentication, so it can represent more than a manually supplied cookie. See the authentication guide.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Login flows may set cookies across redirects. The guide’s example waits for the final URL or for a page state proving login is complete before saving state. That avoids saving too early, before authentication has finished.
Rank #3
- 【Full HD 1080P Webcam】Powered by a 1080p FHD two-MP CMOS, the NexiGo N60 Webcam produces exceptionally sharp and clear videos at resolutions up to 1920 x 1080 with 30fps. The 3.6mm glass lens provides a crisp image at fixed distances and is optimized between 19.6 inches to 13 feet, making it ideal for almost any indoor use.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 8, 10 & 11 / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
- 【Built-in Noise-Cancelling Microphone】The built-in noise-canceling microphone reduces ambient noise to enhance the sound quality of your video. Great for Zoom / Facetime / Video Calling / OBS / Twitch / Facebook / YouTube / Conferencing / Gaming / Streaming / Recording / Online School.
- 【USB Webcam with Privacy Protection Cover】The privacy cover blocks the lens when the webcam is not in use. It's perfect to help provide security and peace of mind to anyone, from individuals to large companies. 【Note:】Please contact our support for firmware update if you have noticed any audio delays.
- 【Wide Compatibility】Works with USB 2.0/3.0, no additional drivers required. Ready to use in approximately one minute or less on any compatible device. Compatible with Mac OS X 10.7 and higher / Windows 7, 10 & 11, Pro / Android 4.0 or higher / Linux 2.6.24 / Chrome OS 29.0.1547 / Ubuntu Version 10.04 or above. Not compatible with XBOX/PS4/PS5.
Capture a screenshot in a standalone script or test
Standalone script
Use await page.screenshot({ path: 'screenshot.png' }) to write an image. Add fullPage: true when the capture should extend beyond the visible viewport, as in the example above.
Playwright test output
In a test, use testInfo.outputPath('screenshot.png') to obtain a test output path. The official TestInfo API example passes that path to page.screenshot().
Rank #4
- 1080P Webcam with Cover for Video Calls - EMEET computer webcam provides design and Optimization for professional video streaming. Realistic 1920 x 1080p video, 5-layer anti-glare lens, providing smooth video. C960 computer camera delivers 1920x1080 video with fixed focus (11.8–118.1 inches), so as to provide a clearer image. C960 USB webcam has a cover and can be removed automatically to meet your needs for privacy. For optimal image performance, use the webcam in a well-lit environment.
- Built-in 2 Omnidirectional Mics - EMEET webcam with microphone for desktop features 2 built-in omnidirectional microphones, picking up your voice to create clear audio for communication. When installing the webcam, select EMEET C960 as the default microphone input device in your computer and video applications and select C960 as the default device in Zoom/Teams and ensure microphone permissions are enabled for proper use. Please note that C960 does not include built-in speakers.
- Automatic Light Adjustment - Automatic exposure adjustment is applied in EMEET HD webcam 1080p so that the streaming webcam can deliver stable image performance. EMEET C960 camera for computer also features color adjustment and exposure optimization to help you look your best. For optimal video quality, it is recommended to use the webcam in normal or well-lit environments and select suitable video settings in your application. Proper lighting helps achieve a clearer and more balanced image.
- Plug-and-Play & Upgraded USB Connectivity - New C960 webcam features both USB Type-A & A-to-C adapter connections for wider compatibility. For stable performance, connect the webcam directly to the computer's main USB port and ensure the device is recognized correctly. If a hub or docking station is used, please ensure it provides sufficient power and stable data transmission, as limited ports may affect performance. 90° wide-angle lens captures more participants without frequent adjustments.
- High Compatibility & Multi Application - C960 webcam for laptop is compatible with Windows 10/11, macOS 10.14+, and Android TV 7.0+. Not supported: Windows Hello, TVs, tablets, or game consoles. It works with Zoom, Teams, Facetime, Google Meet, YouTube and more. Please select C960 webcam as the default camera and microphone device in your application and ensure camera/microphone permissions are enabled, especially on macOS. (Tips: Incompatible with Windows Hello)
Protect cookie values and saved state
Raw session cookies and authentication-state files are credentials: anyone who obtains valid state may be able to impersonate the user or test account. Keep test credentials restricted, supply secrets through your team’s secret-management mechanism, and add playwright/.auth to .gitignore. Playwright warns against checking authentication state into a repository, including a private one.
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 & 11Avoid setting a Cookie request header
Do not try to seed a browser cookie by passing a Cookie header through route.continue({ headers }). Playwright documents Cookie as a forbidden request header that cannot be overridden this way and directs users to browserContext.addCookies() for custom cookies. See the Route API.
Best Value
- Compatible with Nintendo Switch 2’s new GameChat mode
- HD lighting adjustment and autofocus: The Logitech webcam automatically fine-tunes the lighting, producing bright, razor-sharp images even in low-light settings. This makes it a great webcam for streaming and an ideal web camera for laptop use
- Advanced capture software: Easily create and share video content with this Logitech camera that is suitable for use as a desktop computer camera or a monitor webcam
- Stereo audio with dual mics: Capture natural sound during calls and recorded videos with this 1080p webcam, great as a video conference camera or a computer webcam
- Full HD 1080p video calling and recording at 30 fps. You'll make a strong impression with this PC webcam that features crisp, clearly detailed, and vibrantly colored video
Troubleshoot authentication screenshots
- The screenshot shows a login page: Check that the cookie value is current and belongs to the test account, that its name and scope match the application, and that you added it to the same context as the screenshot page.
- The cookie is missing on the target host: Confirm the cookie uses the right
url, or a matchingdomainandpath. A domain cookie intended for subdomains may require a leading dot. - The cookie API rejects the cookie: Supply either
urlor bothdomainandpath; providing only one of the latter pair is insufficient. - The page redirects before the screenshot: Authentication may not be complete, or the cookie may have expired. For a multi-step login flow, wait for the final URL or an authenticated page state before capturing or saving authentication state.
- The script works once but not on later test runs: A manually supplied cookie may not be a suitable repeatable setup. Use a setup project and saved
storageStatewhen the test suite needs to reuse broader browser authentication state. - A routed request does not accept the Cookie header: That header cannot be overridden through
route.continue(); seed the browser context withaddCookies()instead.
Or skip the browser setup
ScreenshotNeo provides a screenshot API and MCP server. For a public page, a single GET request can return an image or PDF; it is not a way to inject a private Playwright session cookie.
cURL example, using the documented endpoint and parameters: see the ScreenshotNeo API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
- Cookie and consent banners are accepted and removed before capture; newsletter popups and chat widgets are also removed. Each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; responses identify the page verdict and billing status in headers.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdffor AI agents and MCP clients. - The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Every feature is on every plan.
Sign up free for 1,000 screenshots a month with no card.
Frequently Asked Questions
Can I add a cookie after creating the page?
Yes, cookies are added to the page’s BrowserContext, but add them before navigation when you need them sent with the initial page request.
Can storageState replace manually adding cookies?
Yes, when you want to reuse saved browser authentication state rather than inject a specific cookie value for a single context.
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.




