iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Use a Playwright BrowserContext to set shared HTTP headers, then open each URL in a page and save its screenshot. Context headers apply to requests from every page in that context, so use separate contexts when URL groups need different credentials or header settings.
Set up Playwright and the output folder
This JavaScript example uses Playwright’s Chromium browser. Install Playwright in your project and install its browser if you have not already:
npm install playwright
npx playwright install chromium
Create a folder named screenshots in the project directory before running the script. The example captures URLs sequentially and writes numbered PNG files.
Capture a list of URLs with shared headers
const { chromium } = require('playwright');
async function captureUrls(urls, headers) {
const browser = await chromium.launch();
const context = await browser.newContext({
viewport: { width: 1440, height: 900 },
});
try {
await context.setExtraHTTPHeaders(headers);
for (const [index, url] of urls.entries()) {
const page = await context.newPage();
try {
const response = await page.goto(url, { waitUntil: 'load' });
await page.screenshot({
path: `screenshots/page-${index + 1}.png`,
fullPage: true,
});
console.log(url, response ? response.status() : 'no response');
} finally {
await page.close();
}
}
} finally {
await context.close();
await browser.close();
}
}
captureUrls(
['https://example.com', 'https://playwright.dev'],
{ 'X-Custom-Header': 'example-value' }
).catch(error => {
console.error(error);
process.exitCode = 1;
});
Replace the sample URLs and header with your own. Header values must be strings. setExtraHTTPHeaders() sends the configured headers with every request initiated by pages in the context—not only the main document—so be deliberate about where you use authorization or other sensitive values. Playwright BrowserContext API
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Choose header scope and context boundaries
Use context headers for a shared batch
Call context.setExtraHTTPHeaders(headers) before navigating. All pages in that context share its settings. A page-specific page.setExtraHTTPHeaders() value takes precedence when it overrides a matching context-level header. Playwright does not guarantee the order of outgoing headers. BrowserContext API
Separate batches with different credentials
If URLs belong to different accounts, trust boundaries, or header configurations, place them in separate contexts. This avoids sending one group’s context-wide headers to another group’s requests. A context can contain multiple pages, and its settings apply to those pages. Playwright pages
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Choose what the screenshot should contain
Viewport or full page
The example sets a 1440-by-900 viewport and uses fullPage: true to capture the full scrollable page. Remove that option, or set it to false, when you need only the visible viewport. Keep viewport dimensions consistent across a batch if you intend to compare screenshots. Page API
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsWait for the page’s actual content
page.goto() supports load, domcontentloaded, networkidle, and commit as navigation completion conditions; its default is load. A page may still render important content after navigation completes. In that case, wait for a meaningful page-specific locator or other readiness signal before taking the screenshot. Playwright discourages using networkidle as a general testing-readiness strategy. Page API
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Scale the batch carefully
The sample is sequential, which is simple to debug and keeps the number of active pages low. If capture time matters, bounded concurrency is an option to evaluate, but there is no universally safe concurrency level established here: choose one based on your resources, target-site behavior, and rate limits. Give each capture a unique output path so parallel tasks do not overwrite one another.
Check results and troubleshoot failures
- Header is missing or rejected: Confirm the header object was passed to
context.setExtraHTTPHeaders()before navigation and that each value is a string. Check whether a page-level header overrides the same context-level name. Header order is not guaranteed. BrowserContext API - Credentials reached an unintended URL: Context headers apply to requests initiated by pages throughout that context. Split URLs with different credentials or trust boundaries into separate contexts.
- Screenshot is blank or incomplete: The navigation condition may have completed before client-side content appeared. Wait for a locator or application-specific signal that represents the content you need; do not assume
networkidleis the right readiness check. Page API - An error page was captured: A valid HTTP error response such as 404 or 500 does not, by itself, make
page.goto()throw. Inspect the returned response status and decide whether your workflow should save or reject that screenshot. Page API - Output file cannot be written: Ensure the
screenshotsdirectory exists and that the process can write to it. Use unique filenames when capturing concurrently. - Visual output differs between runs: Browser rendering can vary with operating system, browser version, hardware, headless mode, and other factors. Keep the capture environment and viewport consistent when comparing against a baseline. Playwright snapshot documentation
Or skip the browser setup
ScreenshotNeo can capture a URL with one GET request. See the ScreenshotNeo API documentation for request options.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo removes cookie and consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 screenshots.
Create a free ScreenshotNeo account to start with 1,000 screenshots a month and no card.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Frequently Asked Questions
Can I reuse one page for every URL?
Yes. This example creates and closes a page for each URL; Playwright also supports multiple pages in a context. Reusing a page is an implementation choice if your workflow does not need each capture isolated.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Does a screenshot indicate that the HTTP request succeeded?
No. Check the navigation response status separately; a server can return an HTTP error page without causing navigation to throw.
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.
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 →

