October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk6 min

How to Capture and Frame Website Screenshots in Nuxt.js

Use Nuxt’s Playwright testing integration to capture a rendered route, full page, component, or fixed crop—and make output dimensions and readiness predictable.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Nuxt’s browser-testing support with Playwright: open the route in a real browser, wait for the page state you want to show, then capture the viewport, full page, or a selected element. Nuxt’s current integration documentation covers Nuxt 4; Playwright supplies the screenshot controls. This approach captures the rendered interface, including client-side behavior, rather than only checking the HTML returned by a server.

Set up browser testing for a Nuxt route

Nuxt documents browser testing through @nuxt/test-utils, including a Playwright test-runner integration and a createPage helper that exposes Playwright APIs. The example below uses the Nuxt 4 documentation and the Playwright test runner. Install the packages in your project using the package manager already in use, then add a test file such as tests/screenshot.spec.ts.

As an Amazon Associate I earn from qualifying purchases.

Nuxt’s documented runner import is @nuxt/test-utils/playwright. Configure the Nuxt root directory in the test setup if your application is not at the test runner’s default root. See the Nuxt testing documentation for the current setup details.

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

Open a route and capture the viewport

import { test, expect } from '@nuxt/test-utils/playwright';

test('captures the home page', async ({ page }) => {
  await page.goto('/', { waitUntil: 'hydration' });
  await expect(page.locator('body')).toBeVisible();
  await page.screenshot({ path: 'artifacts/home.png' });
});

The route in goto is relative to the Nuxt application. The default page screenshot shows the current viewport, so content below the fold is not included. Create the output directory before running the test if your test setup does not create it automatically.

Choose the screenshot framing

Playwright’s Page API covers page screenshots and their options. The right choice depends on whether the image is intended to show a viewport, a long document, a component, or a fixed rectangle.

Goal Playwright call What to expect
Show what fits in the browser viewport page.screenshot({ path: 'viewport.png' }) Viewport-sized image; content below the fold is omitted.
Show the entire scrollable page page.screenshot({ path: 'full.png', fullPage: true }) Tall image including below-the-fold content; less suitable for a compact preview.
Isolate a component selected in the DOM page.locator('.target').screenshot({ path: 'element.png' }) Frames the selected element’s rendered bounds; requires a locator that identifies the intended element.
Crop a fixed region page.screenshot({ path: 'crop.png', clip: { x: 40, y: 80, width: 800, height: 500 } }) Uses the specified page-coordinate rectangle; choose coordinates and dimensions for the intended region.

Full page

await page.screenshot({ path: 'artifacts/full-page.png', fullPage: true });

Use this when the screenshot needs the document’s below-the-fold sections. A full-page capture can be much taller than the viewport, so consider whether a single long image is practical for the destination.

One component

await page.locator('[data-testid="pricing-panel"]').screenshot({
  path: 'artifacts/pricing-panel.png'
});

A stable test identifier can make the target clearer than a styling class that may change during redesign. The locator must resolve to the component you intend to frame, and its screenshot represents the element’s rendered bounds.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Fixed crop

await page.screenshot({
  path: 'artifacts/hero-crop.png',
  clip: { x: 0, y: 0, width: 1200, height: 700 }
});

clip describes the crop rectangle with x, y, width, and height. Prefer a locator screenshot when the target already exists as a stable DOM element; use coordinates when the framing itself is the requirement.

Control output dimensions and appearance

CSS pixels or device pixels

Playwright’s scale option controls output pixel dimensions. Use scale: 'css' for one output pixel per CSS pixel, which can produce smaller, consistent images. Use scale: 'device' when device-pixel detail matters; the resulting image can be larger, particularly in a high-DPI browser context. Check the output dimensions before using screenshots in documentation or image-processing pipelines.

await page.screenshot({ path: 'artifacts/css-scale.png', scale: 'css' });
await page.screenshot({ path: 'artifacts/device-scale.png', scale: 'device' });

Repeatable or privacy-conscious captures

Dynamic timestamps, rotating content, or personal information can make screenshots inconsistent or unsuitable for sharing. Playwright supports screenshot style overrides and locator mask options to modify or cover selected areas. For example, a locator screenshot can mask a region:

await page.screenshot({
  path: 'artifacts/redacted.png',
  mask: [page.locator('[data-testid="account-details"]')]
});

These options change what appears in the image. Document masking or style changes when the screenshot is used as evidence or presented as an unaltered view of the page.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Wait for the state the screenshot should represent

A successful navigation does not always mean the page is ready for a useful image. Nuxt’s official example waits for hydration before checking page content, but there is no universal wait recipe for every route. A route may also depend on authentication, application data, web fonts, images, or delayed UI updates.

  1. Navigate to the target route and choose a readiness condition appropriate to the page. Nuxt’s documented example uses await page.goto('/', { waitUntil: 'hydration' }).
  2. Assert on a meaningful page element or application state instead of relying on an arbitrary pause where possible.
  3. If a particular component or image is essential, wait for that target to be visible or loaded before capturing it.
  4. Set the viewport and any required authentication or test data consistently across runs.
  5. Capture only after the page reaches the state the image is meant to show.

Nuxt supports universal, client-side, hybrid, and edge rendering patterns. Universal rendering is the default in its documentation and returns server-rendered HTML to the browser; route rules can change rendering behavior or caching. A screenshot is the browser’s rendering of a route and state, so it answers a visual question. If the requirement is only to verify server-returned HTML, use a response or markup check instead. See Nuxt rendering modes.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot or PDF; use this cURL example for an image:

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

Replace the target URL with the publicly reachable Nuxt route you want to capture. See the ScreenshotNeo documentation for API options. It accepts cookie or consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks or CAPTCHAs, 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 gives AI agents tools for screenshots, page information, and PDF capture. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, no card required.

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.

Troubleshoot missing or misleading captures

  • The screenshot is blank or incomplete: The route may not have reached the state you intended. Wait for hydration and assert on the relevant page element or content before capturing.
  • Below-the-fold content is missing: The default page screenshot is viewport-only. Set fullPage: true for the full scrollable page.
  • The wrong area is framed: Check that the locator selects the intended element, or recheck the clip rectangle’s coordinates and dimensions.
  • The screenshot size is unexpectedly large: Review scale; 'device' uses device-pixel output, while 'css' uses CSS-pixel dimensions.
  • The image differs between runs: Check whether the route depends on changing data, authentication, viewport, fonts, network-loaded assets, or rendering mode, then make those conditions repeatable.
  • The output file is not written: Ensure the destination directory exists and that the test process can write to it.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep capture costs and reliability in view

With a local Playwright test, capture runs as part of the browser-testing workflow; the main practical costs are browser execution time, image size, and the effort needed to make route state repeatable. Full-page images and device-pixel scale can increase output dimensions. For repeatable visual checks, control the viewport, test data, authentication, and page readiness rather than treating navigation alone as proof the screenshot is ready.

ScreenshotNeo bills only clean shots; bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. Its plans are Free: 1,000 shots/month; Starter: $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. Every feature is on every plan. These are ScreenshotNeo plan terms, not costs for the local Playwright workflow.

Frequently Asked Questions

Does a Playwright page screenshot include content below the fold by default?

No. The default captures the viewport; set fullPage: true to capture the full scrollable page.

Should I use a locator screenshot or clip for a Nuxt component?

Use a locator screenshot when the component has a stable DOM locator. Use clip when you need a specific coordinate-based rectangle.

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

Does a Nuxt screenshot verify server-rendered HTML by itself?

It captures the browser-rendered route and state. A response or markup check is more appropriate when you need to verify only server-returned HTML.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.