Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A Playwright “page closed,” “target closed,” or similar screenshot error means the screenshot call can no longer use the browser object it was given. It does not, by itself, explain why. First identify whether the Page, its BrowserContext, or the Browser closed; then check teardown and fixture ownership before investigating crashes, resource pressure, or page-specific behavior.

The steps below help isolate the cause without assuming that one reported issue applies to every Playwright version or setup.

1. Check which Playwright object closed

A screenshot is taken from a Page, but that page depends on its owning context and browser. Any of those objects may have been closed or lost. Playwright’s Page API provides page.isClosed(); its documented description is “Indicates that the page has been closed.” Check that state immediately before the screenshot, and inspect the lifetimes of all three objects.

import { chromium } from 'playwright';

const browser = await chromium.launch();
const context = await browser.newContext();
const page = await context.newPage();

try {
  await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });

  if (page.isClosed()) {
    throw new Error('The page was closed before screenshot capture');
  }

  await page.screenshot({ path: 'page.png' });
} finally {
  await context.close();
  await browser.close();
}

This pattern makes ownership and cleanup explicit. If your application or test harness already owns a browser, do not add a second cleanup path that closes it while another task still needs it. Search the codebase for page.close(), context.close(), and browser.close(); also inspect helper functions and test hooks that may call them indirectly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
HP OmniBook 3 17.3 inch Laptop PC, FHD Display, AMD Ryzen 3 30, 8 GB RAM, 512 GB SSD, AMD Radeon 610M Graphics, Windows 11 Home, Mica Silver, 17-dp0199nr
  • FULL HD IPS DISPLAY - Enjoy vibrant, crystal-clear images with 178-degree wide-viewing angles
  • AMD RYZEN 3 30 PROCESSOR - Everyday performance you can count on; Multitask, stream, game casually, and edit photos smoothly with responsive power and vibrant HDR visuals
  • ENJOY UP TO 14 HOURS AND 15 MINUTES OF BATTERY LIFE - HP Fast Charge restores battery from 0 to 50% in approximately 45 minutes
  • AMD RADEON 610M GRAPHICS - Experience smooth entertainment; Built for streaming and multitasking, enjoy realistic visuals and efficient performance for work and play
  • STORAGE AND MEMORY - 512 GB PCIe NVMe M.2 SSD offers fast speed and efficient storage; and 8 GB LPDDR5 RAM memory boosts performance with higher bandwidth
  • Page closed: the specific tab is no longer available. Check navigation handlers, test cleanup, and code that closes pages after a task.
  • Context closed: pages created in that context cannot continue as if it were open. Check fixture teardown and shared-context ownership.
  • Browser closed or disconnected: the owning browser process or remote connection may have ended. Check browser shutdown, process logs, and connection lifetime.

A state check is a diagnostic aid, not a lock: another task could close the page after isClosed() returns false. The important fix is to ensure the screenshot completes before the owner closes the page, context, or browser.

2. Check async flow and cleanup order

A common class of bug is starting screenshot work without awaiting it, then allowing a finally block, test hook, or enclosing function to close the browser. Await the capture in the same lifetime that owns the page:

// Correct: the function does not finish and run cleanup until capture finishes.
await page.screenshot({ path: 'page.png' });

// Risky: capture is started but not awaited; surrounding cleanup may run first.
page.screenshot({ path: 'page.png' });

Look for unawaited promises, early returns, rejected navigation or setup steps, and cleanup in both per-test and global hooks. If capture runs in a background task, coordinate its completion before closing the context. Avoid “fixing” the error by suppressing it: that can hide a lost screenshot or a broken test lifecycle.

3. Inspect Playwright Test fixtures and browser reuse

When the error occurs only in tests, follow fixture setup and teardown in execution order. Determine who creates the page, who owns its context, and whether a built-in fixture or extension also manages the browser. A 2023 report involving Playwright 1.30.0 described a custom page being closed before the test ran when built-in fixtures were combined with the VS Code extension’s browser-reuse option. The reporter found fixture order relevant; this is an example to investigate, not proof that VS Code or fixture order causes every closed-page error.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
HP 14" HD Chromebook Laptop for Students, Intel Quad-Core N4120(> N4020), 4GB RAM, 64GB eMMC, WiFi, Webcam, HDMI, USB-A&C, 14 Hours Battery Life, Zoom, Chrome OS, CUE Accessories
  • Intel Celeron N4120: 4 Cores & Threads, 1.1GHz Base Clock, Up to 2.6GHz Boost Clock, 4MB Cache, Intel UHD Graphics 600. The perfect combination of performance, power consumption, and value helps your device handle multitasking smoothly and reliably with four processing cores to divide up the work.
  • 14" HD Display: 14.0-inch diagonal, HD (1366 x 768), micro-edge, anti-glare. See your digital world in a whole new way. Enjoy movies and photos with the great image quality and high-definition detail of 1 million pixels.
  • Memory & Storage: 4 GB LPDDR4x & 64 GB eMMC Storage. Adequate high-bandwidth RAM to smoothly run multiple applications and browser tabs all at once. An embedded multimedia card provides reliable flash-based storage.
  • Ports:2 x USB 3.0 Type-A,1 x USB 3.0 Type-C,1 x HDMI,1 x Headphone Jack
  • Chrome OS: Chromebook is a computer for the way the modern world works, with thousands of apps. Enjoy the seamless simplicity that comes with Google Chrome and Android apps, all integrated into one laptop. It’s fast, simple, and secure.
  1. Identify whether the page comes from a built-in fixture, a custom fixture, or a manually created context.
  2. Read the fixture dependencies and teardown code. Confirm that the page is not closed before the test body or screenshot helper uses it.
  3. Temporarily disable browser reuse or custom fixture composition, changing one variable at a time.
  4. Run a single test without parallel workers. If it passes only in isolation, investigate shared state and competing cleanup.

Keep a clear ownership rule: the component that creates a browser, context, or page should define when it is closed, and consumers should not independently close a shared object unless that is part of the design.

4. If the page seems open, investigate crashes and resource pressure

A page can become unavailable because its browser process crashed or stopped responding, rather than because your code intentionally closed it. Check browser-process output, container or system logs, memory use, and the timing of the failure. Note whether it follows many navigations, occurs only under concurrency, or appears after a long-lived browser session.

Individual issue reports illustrate why this branch is worth checking, but do not establish universal causes: a Playwright 1.40.0 report described Chromium running out of memory after thousands of navigations and hanging at the screenshot call; a separate Playwright 1.45.0 report described occasional “Target crashed” screenshot failures in a multithreaded, long-lived setup. Treat those as clues for diagnosis, not as evidence that your failure has the same cause.

  • Record memory and process counts before and during a failing run; look for growth over time rather than assuming a fixed threshold.
  • Reduce worker count and concurrency, then compare against the failing setup.
  • Try a fresh, short-lived browser/context for the same capture. If that changes the result, inspect accumulated state and reuse boundaries.
  • Preserve the browser’s stderr and relevant container logs. A screenshot error alone may omit the earlier crash signal.

Do not increase timeouts as the first response to a crashed target. A longer wait helps only when the target remains alive and is merely slow; it does not revive a closed page or browser process.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
AKCHART 15.6'' AI Laptop with Office 365 12GB RAM 256GB SSD Win 11 Laptops
  • Stunning 15.6" FHD IPS Display: Experience crisp 1920x1080 resolution on this 15.6 inch laptop with an IPS panel that delivers wide viewing angles and vivid colors. The narrow-bezel design maximizes screen real estate for comfortable viewing on this Win 11 laptop, whether you're studying or working.
  • Celeron J4105 Processor & 256GB SSD: Powered by a reliable Celeron J4105 processor paired with 12GB DDR4 memory and a fast 256GB M.2 SSD. This laptop computer supports SSD expansion up to 2TB and TF card expansion up to 1TB, so your storage grows with your needs. Delivers smooth multitasking for daily productivity.
  • AI-Powered Win 11 Laptop: Built-in AI features enhance your productivity with smart assistance for writing, summarizing, and task management. Pre-installed with Win 11 and includes Office 365 subscription. This student laptop is backed by 1-year warranty and 24/7 customer support.
  • All-Day 7000mAh Battery & 180° Hinge: The high-capacity 7000mAh battery keeps this laptop powered through long classes or meetings. The 180-degree lay-flat hinge lets you share your screen effortlessly during presentations. This durable laptop computer adapts to your dynamic workflow.
  • Versatile Connectivity Hub: Equipped with USB 3.2, Type-C, Mini HDMI, and 3.5mm audio jack to connect all your peripherals. Stay online anywhere with high-speed 5G WiFi and Bluetooth 4.2. This college laptop keeps you connected at home, in the library, or on the go.

5. Separate site behavior from capture mode

If one URL fails while another works, compare the failing site with a minimal or known-good page. A Playwright 1.39.0 issue report described a 30-second full-page screenshot timeout on a particular site while other sites worked. That report demonstrates the value of isolating the target; it does not establish a general fix for full-page captures.

Run controlled comparisons, keeping the Playwright version and browser engine the same:

  • Target: failing site versus a simple page.
  • Capture area: viewport screenshot versus fullPage: true.
  • Lifetime: a new page and context versus the long-lived or reused setup.
  • Workload: a single capture versus the concurrent workload that fails.

For example, this viewport capture is a useful baseline before testing full-page behavior:

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.screenshot({ path: 'viewport.png' });

// Test separately after the baseline succeeds.
await page.screenshot({ path: 'full-page.png', fullPage: true });

If only full-page capture fails, the comparison has narrowed the problem to that capture mode or the target’s page behavior; it has not yet proved a specific root cause.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
HP Essential Laptop 2026, Intel CPU, 128GB Storage, Office 365, Windows 11
  • Efficient Performance for Everyday Computing: Powered by Intel N150 processor with up to 3.6 GHz Intel Turbo Boost Technology, 6 MB L3 cache, 4 cores, and 4 threads, this HP laptop delivers responsive performance for web browsing, streaming, document editing, and multitasking. Paired with 4GB LPDDR5 RAM and 128GB UFS storage, it handles daily tasks smoothly. Includes 1-year Microsoft 365 Personal subscription for Word, Excel, PowerPoint, and cloud storage to maximize your productivity.
  • 14-Inch HD Micro-Edge Display:Enjoy clear visuals on the 14-inch HD (1366 x 768) anti-glare screen with 250-nit brightness and 62.5% sRGB coverage. The micro-edge bezel delivers a 79% screen-to-body ratio in a compact design. An HP True Vision 720p HD camera with noise reduction and dual-array microphones supports clear video calls, remote work, and online learning.
  • Modern Connectivity and Wireless Technology: Stay connected with Wi-Fi 6 (2x2) for faster wireless speeds and Bluetooth 5.4 for seamless pairing with accessories. Versatile port selection includes 1 USB Type-C 10Gbps with DisplayPort 1.2 for external displays, 2 USB Type-A 5Gbps ports for peripherals, 1 HDMI 1.4b port, 1 headphone/microphone combo jack, and 1 multi-format SD media card reader. Connect monitors, transfer files quickly, and expand your workspace with ease.
  • All-Day Battery Life and Portable Design: Enjoy up to 11 hours of video playback, 7.5 hours of mixed usage, or 7.5 hours of wireless streaming on a single charge, perfect for students and professionals on the go. Weighing just 3.24 lb and measuring 12.76" x 8.86" x 0.71", this lightweight laptop fits easily in backpacks and bags. The stylish willow green top cover with matte finish and natural silver keyboard deck with vertical brushing pattern offer a modern, professional look.
  • AI-Enhanced Productivity: Access Microsoft Copilot instantly with the dedicated Copilot key for faster assistance. AI Noise Reduction filters background sounds and improves voice clarity during calls. Dual speakers provide clear audio, while the full-size natural silver keyboard and HP Imagepad support comfortable typing and navigation.

6. Compare remote connection with local launch

If the failure occurs only with a remote browser, reproduce the same URL and screenshot using a locally launched browser where possible. Keep the browser engine, Playwright version, and capture options constant so the connection mode is the main changed variable. A report from an older Playwright version documented a screenshot hang with a BrowserServer connection and contrasting local-launch behavior in its particular Docker setup. It is a useful reproduction axis, not a current universal diagnosis.

Record how the remote browser is started and connected, where it runs, and whether the connection is still alive when capture begins. If local launch works but remote capture fails, focus the investigation on connection lifetime, remote process health, and environment differences rather than changing screenshot options at random.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

7. Capture a minimal, useful reproduction

When the cause is still unclear, reduce the failing case to one page and one screenshot, then include the environment details that can change the outcome:

  • Exact error text and Playwright call log.
  • Playwright package and language-binding version, browser engine, and operating system or container.
  • Local launch or remote connection, plus the relevant launch or connection setup.
  • Viewport or full-page capture; the target URL or a safely shareable minimal page.
  • How long the browser and page have been running, and whether the run is concurrent or long-lived.
  • Fixture setup, teardown, and nearby cleanup code.

Issue reports across Playwright 1.30.0, 1.39.0, 1.40.0, and 1.45.0 describe different environments and outcomes. Keep the version and browser engine explicit, and confirm any proposed version-specific fix against the version you run. The reports do not provide a population-level rate or show that any one cause is typical.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
15.6 Inch Laptop with FHD display, 6GB RAM 128GB Storage Expandable 512GB
  • Portable Lightweight Design: Weighing just 3.6 lbs, the Laptop S7HI is portable, making it perfect for travel, work, and school. Its slim profile and 15-inch HD IPS display offer a great balance of size and portability for everyday use
  • Powerful Processor: With a base frequency 1.9GHz Intel 5205U processor, this laptop handles multiple tasks efficiently. Whether you're working, studying, or streaming, enjoy a smooth experience with reliable performance
  • Ample Storage with Expansion: 128GB of internal storage with an extra 512GB expansion slot offers plenty of room for your documents, photos, and videos. Ideal for students and professionals needing more space for files and projects
  • Pre‑Installed Windows 11: Ready to Use Comes with a genuine Windows 11 system pre‑loaded, offering a clean, intuitive interface and broad software compatibility. Open the box, power on, and you're all set for school assignments, business reports, or daily computing needs.
  • Comprehensive Connectivity Options: Equipped with Type-C, HDMI, SD Card Reader, and more, this laptop offers flexible connectivity. Stay connected via dual-band WiFi and Bluetooth 4.2, ensuring fast internet access and peripheral support

Troubleshooting symptoms and next checks

Symptom First check Next step
page.isClosed() is true before capture Find the code or fixture that owns and closes the page. Correct cleanup order; await the screenshot before teardown.
Page is open, but target/browser errors occur Check browser-process output, memory, and process health. Reduce concurrency and compare a fresh, short-lived context.
Only one URL fails Compare with a minimal or known-good page. Test viewport and full-page capture separately.
Only remote mode fails Verify the remote process and connection remain alive. Compare with local launch while keeping other variables constant.
Failure appears only in tests or with reuse enabled Trace fixture ownership and teardown order. Run one test without reuse or parallel workers to isolate lifecycle interactions.
Failure follows many pages or long runs Check memory, concurrency, and browser lifetime. Compare a fresh browser/context and retain process logs.

Or skip the browser setup

If you need a screenshot rather than a Playwright-specific browser workflow, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return an image or PDF. It removes supported cookie/consent banners, newsletter popups, and chat widgets before capture; failed loads, bot checks, blank pages, and cache hits are not billed. Its MCP server lets AI agents use screenshot tools. See the API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

Screenshot output and browser automation are not interchangeable: use Playwright when you need to interact with a page or control its lifecycle, and use the API when a returned capture is enough. ScreenshotNeo includes 1,000 screenshots per month on the free plan with no card required; paid plans start at $5 for 3,000. Sign up for the free plan.

Frequently Asked Questions

Does `page.isClosed()` tell me why a screenshot failed?

No. It reports whether the page is closed at the time you check; it does not identify which code path closed it or explain a browser crash.

Should I retry a screenshot after a closed-target error?

Only after confirming the page and its owning context or browser are still usable, or after creating a new page in a live context. Retrying against the same closed object cannot restore it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can a full-page screenshot itself close the page?

The evidence here does not establish that as a general cause. Compare viewport and full-page captures on the same target and environment to determine whether the failure is specific to that case.

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.