To capture a “popup” correctly, first identify what the browser is showing: a new tab or window, a JavaScript alert/confirm/prompt, or a modal overlay rendered inside the page. In Playwright, wait for a new page before clicking the opener, then screenshot that Page. For an in-page modal, wait until its locator is visible and screenshot the page or the modal element. Native JavaScript dialogs are not ordinary page content; handle them with dialog APIs, and do not expect a normal webpage screenshot to include the browser chrome.
Identify the kind of popup
The word popup describes three different browser behaviors. Your capture code depends on which one the site uses.
Browser-created page or window
A link or button can open a new tab or window. In Playwright, that destination is a separate Page in the same browser context. Capture it independently from the page that opened it. A screenshot of the opener will not automatically include the new page.
Native JavaScript dialog
alert(), confirm(), prompt(), and a beforeunload confirmation are browser dialogs, not DOM elements. They block normal page interaction. Playwright auto-dismisses these dialogs when no handler is installed. If your test must read the message or choose an outcome, register a handler before triggering the action.
#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
In-page modal overlay
A cookie notice, newsletter prompt, login panel, lightbox, or custom dialog can be ordinary HTML positioned over the page. It is captured as rendered page content after it becomes visible. You can capture the full viewport, the full page, or only the modal element.
Capture a new popup page with Playwright
The critical ordering rule is to start waiting for the popup before clicking the control that opens it. This prevents a race in which the new page is created before your code begins listening.
Complete JavaScript example
import { chromium } from 'playwright';
const browser = await chromium.launch();
const context = await browser.newContext({ viewport: { width: 1440, height: 1000 } });
const opener = await context.newPage();
await opener.goto('https://example.com', { waitUntil: 'domcontentloaded' });
const popupPromise = opener.waitForEvent('popup');
await opener.getByRole('button', { name: 'Open details' }).click();
const popup = await popupPromise;
await popup.waitForLoadState('domcontentloaded');
// Viewport screenshot of the popup page.
await popup.screenshot({ path: 'popup-viewport.png' });
// Full rendered document, including content below the fold.
await popup.screenshot({ path: 'popup-full-page.png', fullPage: true });
await browser.close();
Use a locator that describes the actual control, such as a role and accessible name, instead of relying on a brittle text fragment. If the popup performs a slow client-side render, wait for a meaningful element or network condition after the initial load.
When the popup is opened by a link
const popupPromise = page.waitForEvent('popup');
await page.locator('a[target="_blank"]').click();
const popup = await popupPromise;
await popup.waitForLoadState('networkidle');
await popup.screenshot({ path: 'new-tab.webp', type: 'webp' });
networkidle can be unsuitable for applications that keep connections open. In that case, wait for a stable selector instead:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC 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 & 11await popup.locator('[data-testid="report"]')
.waitFor({ state: 'visible', timeout: 15000 });
await popup.screenshot({ path: 'report.png', fullPage: true });
Distinguish a popup from a new browser context
page.waitForEvent('popup') observes a page opened by the current page. A separately launched context or browser is not a popup event; retain the returned context or page reference and capture it directly. If the site opens a tab through a script after a delay, install the listener first and use an explicit timeout appropriate for your application.
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
Capture an in-page modal or overlay
For a DOM modal, make the site display it, wait for its visible state, and then choose the image area you need.
Capture only the modal
const modal = page.locator('[role="dialog"]');
await page.getByRole('button', { name: 'Show help' }).click();
await modal.waitFor({ state: 'visible' });
await modal.screenshot({ path: 'help-modal.png' });
Element screenshots are useful for documentation, visual regression fixtures, and tickets where the surrounding page is noise. The selector must match the site’s actual markup; [role="dialog"] is only an example.
Capture the modal with its backdrop
A modal element screenshot normally excludes a backdrop implemented by a sibling or pseudo-element. Capture the page viewport when the backdrop matters:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesawait modal.waitFor({ state: 'visible' });
await page.screenshot({ path: 'modal-with-backdrop.png' });
For a reproducible result, set the viewport, color scheme, locale, timezone, and any required authentication before opening the modal. Disable animations with injected CSS if transitions cause inconsistent frames:
await page.addStyleTag({ content: `
*, *::before, *::after {
animation: none !important;
transition: none !important;
}
` });
Full-page versus viewport output
- Viewport screenshot: captures what a user currently sees, including a fixed overlay.
- Full-page screenshot: captures the document’s scrollable content; fixed-position elements can appear according to browser rendering behavior rather than as a stitched, interactive window.
- Element screenshot: captures the selected modal or popup component only.
Handle alert, confirm, prompt, and beforeunload dialogs
Native dialogs must be handled before the action that triggers them. Playwright’s dialog event exposes the type and message; prompt dialogs also expose the default value.
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.
Accept an alert and verify its text
page.once('dialog', async dialog => {
if (dialog.type() !== 'alert') throw new Error(`Unexpected dialog: ${dialog.type()}`);
console.log(dialog.message());
await dialog.accept();
});
await page.getByRole('button', { name: 'Delete' }).click();
Choose an outcome for confirm
page.once('dialog', async dialog => {
if (dialog.type() === 'confirm') {
await dialog.dismiss();
} else {
await dialog.accept();
}
});
await page.getByRole('button', { name: 'Remove item' }).click();
Supply text to a prompt
page.once('dialog', async dialog => {
if (dialog.type() !== 'prompt') return dialog.dismiss();
await dialog.accept('approved by test');
});
await page.getByRole('button', { name: 'Enter name' }).click();
A standard webpage screenshot captures the rendered document, not the browser-native dialog as a regular DOM node. If the requirement is a visual image of the native dialog itself, use an operating-system or browser-window capture tool in addition to Playwright; the page screenshot API alone is not designed for that chrome.
Selenium alternative for native dialogs
Selenium exposes alert, confirm, and prompt handling through its alert interface. Switch to the alert after triggering it, read its text, then accept or dismiss it.
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("https://example.com")
driver.find_element(By.ID, "delete").click()
alert = driver.switch_to.alert
print(alert.text)
alert.dismiss()
driver.quit()
Whitespace before driver in the snippet should be removed if your formatter flags indentation; the operational sequence is what matters: trigger, switch, inspect, then accept or dismiss. Selenium’s alert API does not turn a native dialog into page DOM that a normal element screenshot can capture.
Make popup screenshots deterministic
Wait for the right readiness signal
- Wait for the popup page event before the click.
- Use
domcontentloadedfor basic markup, then wait for a selector that proves the application is ready. - For a modal, wait for
visible, not merely for the element to exist. - Allow lazy images and fonts to finish before capture when visual completeness matters.
Control environment differences
- Set a fixed viewport and device scale factor when pixel dimensions matter.
- Set locale, timezone, and geolocation if the popup content varies by region.
- Provide authentication, cookies, custom headers, or an appropriate user agent for protected flows.
- Freeze animations and avoid random data, rotating banners, and time-dependent labels.
Choose an output format
PNG is lossless and suited to visual comparisons. JPEG is smaller but introduces compression artifacts. WebP often offers a smaller file with good visual quality. Playwright selects the format from the filename extension or an explicit type option.
Troubleshoot common failures
No popup event is received
The control may open an in-page modal, navigate the current page, or be blocked by a popup policy. Confirm the behavior manually and install the event listener before clicking. If it opens a new tab through a context-level action, listen for the browser context’s page event instead of the opener’s popup event.
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
The screenshot is blank or incomplete
Wait for a meaningful content locator, not just the first navigation event. Check that the page did not fail authentication, hit a bot check, or return an error document. Increase the action timeout only after fixing the readiness condition.
Free tools Windows power users keep installed
One-click scans. No signup required.
The modal is present but not captured
It may be hidden behind another state, rendered in an iframe, or attached under a shadow root. Target the correct frame or component, scroll it into view, and wait for visibility. If a backdrop is required, capture the page rather than only the modal node.
The alert causes the test to hang
Install a dialog handler before the triggering action. A handler that never calls accept() or dismiss() leaves the dialog blocking the page.
Images differ between runs
Fix viewport and scale, disable motion, wait for fonts and lazy images, and remove changing content with test data or CSS. Compare the same capture area; full-page stitching and viewport captures answer different questions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Performance, reliability, and cost considerations
Popup capture time is dominated by navigation, JavaScript execution, third-party resources, image loading, and any waits you add. A selector-based readiness wait is usually more predictable than an unconditional long delay. Blocking ads, trackers, or irrelevant resource types can reduce variability, but do so only when those resources are not part of the popup you are documenting.
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.
For test suites, reuse a browser process and create isolated contexts rather than launching a new browser for every image. Keep screenshots at the smallest required viewport and format, and retain diagnostic HTML, console logs, and URLs when a capture fails. Native dialogs require a handler on every path that can trigger one.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. It can wait for a selector, delay, or network idle; capture a CSS-selected element; run custom JavaScript; click before capture; set headers, cookies, user agent, timezone, and geolocation; block selected requests; and load lazy images for full-page shots.
It removes cookie and consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP tools—take_screenshot, get_page_info, and capture_pdf—let Claude, Cursor, or another MCP client request captures.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all options and response details.
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`${res.status} ${res.statusText}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo’s cleaning is designed for page-authored overlays; it does not turn a browser-native alert into ordinary webpage pixels. Plans include every feature: the Free plan provides 1,000 shots per month with no card, Starter is $5 for 3,000, Growth $15 for 15,000, Pro $39 for 60,000, Scale $99 for 250,000, and Business $249 for 1,000,000. Yearly billing gives two months free. Sign up free to get 1,000 screenshots a month with no card.
Which method should you use?
| Popup type | Best capture method | What the image contains |
|---|---|---|
| New tab or window | Playwright popup event, then popup.screenshot() |
The separate popup page |
| DOM modal or overlay | Wait for a locator, then page or element screenshot | The rendered modal, with or without backdrop |
| Alert, confirm, prompt, beforeunload | Dialog handler; use OS/browser capture if the dialog pixels are required | Not included as normal page DOM |
| Many URLs or scheduled captures | ScreenshotNeo API or MCP server | Cleaned image or PDF, with verdict and billing headers |
Frequently Asked Questions
Can Playwright combine the opener and popup into one screenshot?
No. A popup is a separate page, so capture both pages separately and compose the images with an image-processing step if a single composite is required.
Will a full-page screenshot include a fixed popup while scrolling?
It captures the document’s scrollable content; fixed overlays may not appear as a user would see them at every scroll position. Use a viewport screenshot for the visible fixed state.
Can I screenshot a JavaScript alert with an element locator?
No. Alerts are browser-native dialogs. Handle them through the dialog API; use a window or operating-system capture tool when the dialog’s visual pixels are required.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
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.

