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

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

The dependable way to screenshot an Astro website is to use Playwright: start your Astro site, navigate a browser to its URL, and call Playwright’s screenshot API. Use fullPage: true for the entire scrollable document or a locator’s screenshot() method for one component. Astro’s official testing guide recommends Playwright for end-to-end tests across Chromium, WebKit and Firefox.

What you need before capturing an Astro page

  • An Astro project with dependencies installed.
  • A page available at a local development URL such as http://localhost:4321/, or a production-like preview server.
  • Playwright installed in the project.
  • A JavaScript or TypeScript test file and a folder where image files can be written.

Playwright is a browser automation and testing API, not an Astro-specific screenshot command. Astro’s documentation uses it because it can render your pages in modern browser engines and then expose the normal page and locator screenshot methods.

Install Playwright in your Astro project

Run the initializer that matches your package manager from the project root:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
npm init playwright@latest
pnpm create playwright
yarn create playwright

The initializer asks whether to use JavaScript or TypeScript, where to put tests, and whether to add a workflow. Accepting the defaults creates a Playwright configuration and example test files. If your project already has Playwright, you can keep its existing configuration and add a new test.

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Start the Astro site you want to capture

Development server

For a page you are actively building, start Astro in another terminal:

npm run dev

Then confirm the page opens at http://localhost:4321/ (or the port printed by Astro). Keep this process running while the test executes.

Production-like preview

To capture the output of a built site, build first and then use Astro’s preview command:

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.
npm run build
npm run preview

Astro’s Playwright guidance shows a webServer configuration that runs npm run preview for tests. This is useful when you need generated assets, routing and server output close to a deployed build. Use the development server instead when rapid iteration matters.

Take a basic screenshot with Playwright

Create a test such as tests/astro-screenshot.spec.ts:

import { test } from '@playwright/test';

test('capture Astro page', async ({ page }) => {
  await page.goto('http://localhost:4321/');
  await page.screenshot({ path: 'screenshots/home.png' });
});

Run it with:

npx playwright test tests/astro-screenshot.spec.ts

page.goto() loads the Astro page in a real browser context. page.screenshot() writes the rendered viewport to the path you provide. Create the destination directory first if your environment does not create it automatically:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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
mkdir -p screenshots

On Windows PowerShell, use New-Item -ItemType Directory screenshots -Force. The resulting PNG includes only what is visible in the browser viewport unless you request a full-page capture.

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

Capture the full scrollable Astro page

Pass fullPage: true to include content below the fold:

import { test } from '@playwright/test';

test('capture the complete Astro page', async ({ page }) => {
  await page.goto('http://localhost:4321/');
  await page.screenshot({
    path: 'screenshots/home-full.png',
    fullPage: true
  });
});

Use this for documentation, visual review and page archives. A full-page image can be very tall, so consider the output format and downstream image limits. A normal screenshot is better when you need a fixed viewport for a social card or a responsive breakpoint check.

Screenshot one Astro component

Use a locator when the target is a header, article, card or other element rather than the whole document:

import { test } from '@playwright/test';

test('capture the header component', async ({ page }) => {
  await page.goto('http://localhost:4321/');
  await page.locator('.header').screenshot({
    path: 'screenshots/header.png'
  });
});

The selector must match the rendered DOM. Prefer a stable class, ID or testing attribute over a selector tied to incidental markup. If the element is rendered only after client-side code runs, wait for it before capturing:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const hero = page.locator('[data-testid="hero"]');
await hero.waitFor();
await hero.screenshot({ path: 'screenshots/hero.png' });

Choose the URL and browser state deliberately

Local development versus preview

A local development capture shows the page as it exists while you work, including development-server behavior. A preview capture starts from npm run build and is more representative of generated production output. These are different goals; neither URL is universally correct.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • 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.

Routes and query strings

Replace the root URL with the route you need, for example http://localhost:4321/docs/getting-started/. Include query parameters exactly as a visitor would. For a configured baseURL, set it in Playwright’s configuration and navigate with a relative path:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: { baseURL: 'http://localhost:4321' }
});
await page.goto('/docs/getting-started/');

Rendering engines

Astro’s guide describes Playwright testing on Chromium, WebKit and Firefox. Running the same capture in more than one engine can reveal browser-specific layout differences; choose the engine that matches the audience or visual check you are performing.

Make captures deterministic

Visual output can change when fonts, images or client-side data are still loading. Navigate, wait for the state your page requires, then capture:

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.
await page.goto('http://localhost:4321/');
await page.locator('main').waitFor();
await page.screenshot({ path: 'screenshots/ready.png', fullPage: true });
  • Use a stable local fixture or API response when live data changes between runs.
  • Wait for a distinctive element rather than adding an arbitrary long delay.
  • Keep viewport and browser settings consistent when comparing images.
  • Make sure web fonts and images are available to the browser before the capture.

These practices are especially important for screenshot-based visual regression tests, where an asynchronous layout shift can look like a code change.

Configure a preview server in Playwright

If you want Playwright to start Astro automatically, configure the server command in playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  webServer: {
    command: 'npm run preview',
    url: 'http://localhost:4321',
    reuseExistingServer: true
  },
  use: {
    baseURL: 'http://localhost:4321'
  }
});

Build before running the test:

npm run build
npx playwright test

The exact preview port can differ if another process is using it; keep the url and Astro’s configured port aligned.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

Common errors and fixes

“Navigation failed” or connection refused

The Astro server is not running, the URL uses the wrong port, or the preview process was not started. Open the URL in a browser first, then verify the port printed by Astro and update page.goto() or baseURL.

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

Timeout while loading

Check that the route exists and that client-side code is not waiting forever on an unavailable API. For a preview workflow, run npm run build and confirm npm run preview succeeds independently.

Blank or incomplete image

The capture may occur before the component or asset is rendered. Wait for a locator that proves the page is ready, and inspect the page in headed mode to identify runtime errors. Confirm that fonts, images and API responses are reachable from the browser process.

Locator matches nothing

The selector may not exist in the rendered HTML, may be scoped incorrectly, or may depend on a client-side condition. Inspect the page’s DOM, use a stable selector, and call locator.waitFor() when the element appears asynchronously.

Full-page image is unexpectedly tall

fullPage: true intentionally includes the entire scrollable document. Use a viewport screenshot for a fixed-height artifact, or capture a specific locator when only one section is required.

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

Different results on different runs

Changing data, animations, lazy-loaded media and font timing can alter pixels. Use deterministic fixtures, wait for the ready element, and keep the same browser engine and viewport for comparisons.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns PNG, JPEG, WebP or PDF output, so you can capture a deployed Astro URL without installing Playwright or managing a browser process.

See the parameter reference in the ScreenshotNeo documentation. This cURL example saves a WebP file:

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

Equivalent Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Equivalent 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}`);

Before capture, ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info and capture_pdf for Claude, Cursor and other MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free ScreenshotNeo plan.

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

Which capture method should you use?

Goal Method Best fit
See the browser viewport page.screenshot() Fixed-size previews and responsive checks
Include all scrollable content page.screenshot({ fullPage: true }) Documentation and complete-page review
Capture one component page.locator(selector).screenshot() Headers, cards, articles and isolated assets
Automate a deployed URL without local browser setup ScreenshotNeo API or MCP server Scripts, services and AI-agent workflows

Frequently overlooked details

  • The screenshot path is local to the machine running Playwright; it is not automatically uploaded anywhere.
  • A full-page capture reflects the page’s scrollable layout, not a stitched photograph of a physical screen.
  • Capturing a local Astro route requires the server to be reachable from the Playwright process.
  • For a production artifact, build and preview the site rather than assuming the development server has identical output.

Frequently Asked Questions

Does Astro have a built-in screenshot command?

The documented workflow uses Playwright’s browser APIs rather than an Astro-specific screenshot command.

Can I capture only one element?

Yes. Locate the rendered element and call its screenshot() method, optionally after waiting for it to appear.

What does fullPage: true do?

It expands the capture to the page’s complete scrollable content instead of only the current viewport.

Which browsers can Playwright use with Astro?

Astro’s guide describes Chromium, WebKit and Firefox support through Playwright.

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

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.