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
Navigate to the running Next.js page, then call Playwright’s page.screenshot(). By default it saves the visible browser viewport; set fullPage: true for the full scrollable page, or use a locator’s screenshot() method to capture one element. The examples below use Playwright Test with TypeScript.
Set up Playwright and make the Next.js app available
If Playwright is not already installed in the project, the Next.js Playwright guide documents setup with pnpm create playwright and points to the create-next-app Playwright example as a quickstart. Follow the prompts for your project and browser setup. See the Next.js Playwright guide.
The browser must be able to reach the app. Start the development server separately, or have Playwright Test start it using its webServer configuration and wait for it to be available. For a local app using the usual development address, the URL is http://localhost:3000/. You can navigate with that absolute URL or configure a baseURL and use a relative route.
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 & 11For tests that should reflect production behavior more closely, Next.js recommends building and starting the production app before running Playwright. The appropriate choice depends on what you need to capture: a development server is convenient while building a feature, while a production build better represents the built application.
#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
Capture a page: viewport or full page
This minimal Playwright Test example writes a viewport screenshot to screenshot.png in the test process’s working directory:
import { test } from '@playwright/test';
test('save a page screenshot', async ({ page }) => {
await page.goto('http://localhost:3000/');
await page.screenshot({ path: 'screenshot.png' });
});
page.screenshot() captures the current viewport by default. To capture the page’s full scrollable height instead, add fullPage: true:
await page.screenshot({ path: 'screenshot.png', fullPage: true });
Replace the URL with the route you want, such as http://localhost:3000/products. These are Playwright’s documented page screenshot patterns; see Playwright Screenshots.
Wait for the page state you intend to capture
Navigation completing does not necessarily mean that your app’s data, images, or visual effects have reached the state you want. Prefer waiting for a meaningful page condition over adding an arbitrary delay. For example, if the page’s main heading indicates that the expected route has rendered, assert that it is visible before taking the image:
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
import { test, expect } from '@playwright/test';
test('capture the home page', async ({ page }) => {
await page.goto('http://localhost:3000/');
await expect(page.locator('h1')).toBeVisible();
await page.screenshot({ path: 'artifacts/home.png', fullPage: true });
});
The selector is only an example: choose an assertion that represents readiness for your page, such as a route-specific heading or loaded content. This helps avoid saving an image before the element you care about appears; it does not guarantee that every other asynchronous visual change has finished.
Capture one component or keep the screenshot in memory
Capture a component
Use a locator when you want an element rather than the whole page. Playwright scrolls the target into view and performs actionability checks before capturing it:
await page.locator('.header').screenshot({ path: 'header.png' });
Change .header to a selector that uniquely identifies the component. If the locator targets a scrollable container, the screenshot shows only the content currently scrolled into view, not necessarily every item inside that container. Locator screenshots support options such as disabling animations; the Playwright Locator API documents animation handling and stylesheet options.
Process the image in memory
Omit path to receive the screenshot as a buffer. This is useful when passing the image to another library or a pixel-diff workflow instead of writing it directly to a local file:
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.
const image = await page.screenshot();
Playwright documents both page and locator screenshot behavior in its Screenshots guide.
Save screenshots automatically from Playwright Test
For screenshots managed by the test runner, set the use.screenshot option in Playwright Test configuration. Its documented modes are off, on, only-on-failure, and on-first-failure; the default is off. For example, to capture when a test fails:
import { defineConfig } from '@playwright/test';
export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
});
The configuration can also enable full-page screenshots. For test-specific paths or attachments, Playwright documents testInfo.outputPath() and testInfo.attach(). See Playwright TestOptions.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesMake visual captures repeatable
If screenshots serve as visual baselines, keep the route, app state, and execution environment consistent. Playwright notes that rendering can vary with the host operating system, browser version, settings, hardware, power source, and headless mode. Its visual comparison workflow waits for consecutive matching captures and saves a baseline on the first run; later runs compare against it. See Playwright Visual comparisons.
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
- Wait for a meaningful page condition, then handle any known asynchronous content that can still change the image.
- Disable animations when they make the target screenshot unstable; locator screenshot options support animation handling.
- For volatile content, the visual comparison guide documents using a stylesheet to remove it. Mask or hide only areas that are irrelevant to the behavior under review.
- Use the same browser and execution setup when generating and checking baselines, and investigate environment changes before treating every image difference as an app regression.
Troubleshoot common screenshot problems
The browser cannot open the page
Check that the Next.js server is running and that the URL and port in page.goto() match the server. If you use a relative path, verify that Playwright Test has the intended baseURL. If the test starts the server, configure webServer to wait until it is available before the browser navigates.
The screenshot is blank or missing expected content
Confirm that the test navigates to the intended route and wait for a page-specific element or other meaningful readiness condition before capture. Navigation alone may not mean that client-side data or visual effects have settled.
The image shows only part of the page
The default page screenshot covers the viewport. Add fullPage: true to capture the full scrollable page. For a locator screenshot, make sure the selector targets the intended element; if that element is itself a scrollable container, only its currently scrolled content is shown.
Free tools Windows power users keep installed
One-click scans. No signup required.
Visual comparisons change between runs
Check whether the browser version, host environment, headless mode, app state, or dynamic content changed. Keep the comparison environment consistent and stabilize genuinely variable content rather than broadly hiding page regions.
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.
Or skip the browser setup
If you need a screenshot of a publicly reachable page without setting up a browser in your project, ScreenshotNeo provides a website screenshot API and an MCP server. One GET request returns an image or PDF. Its cleanup can accept cookie or consent banners like a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the page verdict and billing status in headers.
For example, this cURL call saves a WebP screenshot of a URL:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Replace YOUR_API_KEY with your key and change the target URL. See the ScreenshotNeo API documentation for request options. ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Learn about ScreenshotNeo and sign up for 1,000 free screenshots a month with no card.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Frequently Asked Questions
Which Playwright method captures only one Next.js component?
Use a locator’s screenshot() method, such as page.locator('.header').screenshot({ path: 'header.png' }).
Can I use a deployed Next.js URL instead of localhost?
Yes. Navigate to the deployed route with page.goto(); the browser running Playwright must be able to reach that URL.
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.

