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

Playwright screenshots contain the page viewport, not the browser window or its address bar. To make the URL visible in a PNG, JPEG, or WebP, read page.url(), inject a fixed label into the document, and call page.screenshot(). If you only need the URL for later identification, store it in a sidecar log or filename instead of changing the pixels.

The direct answer

Playwright does not document a screenshot option that adds the browser address bar or a URL header. The supported screenshot options capture rendered page content, selected elements, the full scrollable page, or an image buffer. The reliable way to show a URL in the image is to render that URL as part of the page immediately before capture.

The current address is available in the Node.js API as page.url(). The following pattern creates a high-z-index label, styles it so long URLs wrap, and captures the modified page. It follows the behavior described in the Playwright screenshots guide and Page API reference.

Inject a visible URL label before the screenshot

Complete JavaScript example

This script launches Chromium, navigates to a page, inserts an idempotent label, captures a full-page PNG, removes the label, and closes the browser. Replace the target URL and adjust the label styles to match your output.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });

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

  const url = page.url();
  await page.evaluate((url) => {
    const oldLabel = document.querySelector('[data-playwright-url-label]');
    oldLabel?.remove();

    const label = document.createElement('div');
    label.dataset.playwrightUrlLabel = 'true';
    label.textContent = url;
    Object.assign(label.style, {
      position: 'fixed',
      top: '0',
      left: '0',
      right: '0',
      zIndex: '2147483647',
      boxSizing: 'border-box',
      padding: '8px 12px',
      background: '#fff',
      color: '#111',
      font: '14px/1.4 sans-serif',
      overflowWrap: 'anywhere',
      boxShadow: '0 1px 4px #0004'
    });
    document.body.appendChild(label);
  }, url);

  await page.screenshot({ path: 'screenshot-with-url.png', fullPage: true });

  // Remove the label if this page will be captured again without it.
  await page.evaluate(() => {
    document.querySelector('[data-playwright-url-label]')?.remove();
  });

  await browser.close();
})();

Install Playwright first with npm install playwright. If your project uses Playwright Test, place the same page.evaluate() and page.screenshot() calls in a test or fixture where page is already available.

Overlay versus pushing the page down

The label above is fixed and overlays the top of the page. That keeps the document layout unchanged, but it can cover a heading or navigation bar. To reserve space, use a normal-flow element instead: insert it as the first child of document.body with position: 'relative', or add matching top padding to the body. A flow element changes layout and therefore can alter responsive wrapping; an overlay does not.

Make repeated captures safe

The data-playwright-url-label marker makes the operation idempotent. Before each capture, remove any prior marker and create one new label. This prevents stacked labels when a loop captures several states of the same page. Remove the element after the shot when later images should represent the unmodified page.

Use the final URL after redirects

Read page.url() only after navigation and any redirect, login, or client-side route change that you want represented. If a single-page application changes routes after loading, wait for the route transition, then read page.url() and inject the label. For a URL containing sensitive query parameters, redact those values before assigning textContent; do not put credentials or session tokens into a public image.

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

Full-page, viewport, and element screenshots

Playwright’s guide describes a full-page screenshot as the entire scrollable page rendered “as if the page was very tall.” A fixed URL label therefore appears at the top of the full-page image, not as a browser toolbar. With fullPage: false (the default), it appears only in the current viewport. If you capture an element with locator.screenshot(), an overlay attached to body may be outside the element’s bounds and will not be included. In that case, put the URL label inside the element being captured or take a page screenshot and crop it afterward.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

For a long page, consider whether the label should appear once at the document top or be repeated on every logical section. A fixed element is captured according to Playwright’s rendering behavior; it is not a print header repeated per page. If you need repeated headers, use the PDF method below.

Keep the URL out of the pixels when possible

If the screenshot is an asset for a build, test report, or archive, changing the page can be undesirable. Save the value returned by page.url() beside the image instead:

const url = page.url();
await page.screenshot({ path: 'checkout.png' });
require('node:fs').writeFileSync(
  'checkout.png.json',
  JSON.stringify({ url, capturedAt: new Date().toISOString() }, null, 2)
);

This preserves the original pixels while keeping a machine-readable association. A filename such as checkout--example.com--2026-09-29.png can help humans, but a sidecar JSON record is safer for long URLs, fragments, and query strings.

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

Use a PDF when you need a documented URL header or footer

Playwright’s PDF API is a separate output path. Its displayHeaderFooter option enables printed headers and footers, and the template classes include url for the document location:

await page.pdf({
  path: 'page.pdf',
  format: 'A4',
  displayHeaderFooter: true,
  headerTemplate: '<div style="font-size:10px;width:100%;padding:0 12mm;"><span class="url"></span></div>',
  footerTemplate: '<div style="font-size:10px;width:100%;text-align:center;"><span class="pageNumber"></span> / <span class="totalPages"></span></div>',
  margin: { top: '18mm', bottom: '18mm' }
});

This creates a PDF, not a raster screenshot. The Page API documents limitations: scripts in header and footer templates are not evaluated, and page styles are not visible inside those templates. Use the HTML overlay when the deliverable must remain a PNG, JPEG, or WebP; use PDF headers when a printed artifact with a URL on each page is acceptable.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Choose the right URL-identification method

Method Output URL visibility Page content changed?
Injected HTML label PNG, JPEG, WebP, or buffer Visible in the captured page Yes, temporarily
Sidecar metadata Original image plus JSON or log Not visible in pixels No
PDF header/footer PDF Documented url template value No page-body overlay, but output is a PDF
Browser-window capture Operating-system image Address bar may be visible Outside Playwright page screenshots

Troubleshooting common failures

The URL label is missing

  • Confirm that page.evaluate() runs after navigation and before page.screenshot().
  • If you are taking an element screenshot, place the label inside that element or capture the page instead.
  • Check that your selector is not being removed by application code; the data attribute makes the label easy to inspect.

The label is behind the site UI

Raise its z-index and create a stacking context with position: fixed. A value such as 2147483647 is commonly above application layers, although a page can still use unusual compositing or browser-specific behavior. If the site applies a transform to an ancestor, test the label in that document context.

The URL is cut off

Long query strings can exceed the viewport. Keep overflowWrap: 'anywhere', allow multiple lines, and use a smaller font or a semi-transparent background. If readability matters more than the exact string, display a redacted URL and write the complete value to metadata.

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

The label changes the layout unexpectedly

A normal-flow label pushes content down and can trigger responsive breakpoints. Use the fixed overlay shown above, or reserve a deliberate amount of space and accept the layout change. Capture at a fixed viewport to make comparisons repeatable.

Content Security Policy blocks the approach

page.evaluate() executes in the page’s context and may work where loading an external script or stylesheet would be rejected by the site’s Content Security Policy. If the application actively removes injected nodes, capture a dedicated test route or use sidecar metadata instead. Do not weaken the production site’s security policy merely to label an image.

The URL shows an intermediate route

Wait for the condition that represents the final state, such as a selector becoming visible or a route-specific response completing. Then call page.url() again immediately before injecting the label. Reading it only before navigation can record the starting URL.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

PDF headers are blank

Set displayHeaderFooter: true, provide sufficient top and bottom margins, and use the documented template classes. Header and footer scripts are not evaluated, and page styles do not flow into the templates, so put required styling inline.

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

Reliability and performance considerations

  • Wait for the state you intend to document. A URL label does not make asynchronous content complete. Use a targeted locator, a controlled delay, or an appropriate navigation condition before capture.
  • Capture once per state. Injecting and removing a small DOM node is cheap compared with navigation and image rendering, but repeated full-page captures can be expensive for very tall pages.
  • Keep the label deterministic. Use fixed font, colors, padding, and viewport dimensions in visual-regression jobs. Avoid timestamps in the visible label unless they are part of the requirement.
  • Protect secrets. URLs can contain tokens, account IDs, or personal data. Redact before rendering, and restrict access to screenshots and metadata.
  • Record both requested and final addresses when redirects matter. Save the input URL separately from page.url() so an audit can distinguish what was requested from where the browser ended.
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 is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF, so you do not have to install or manage a Playwright browser for a straightforward URL capture. Its clean-shot pipeline accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

Use the API documentation at https://screenshotneo.com/docs/ for all options. The basic call is:

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

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(`Screenshot failed: ${res.status}`);
const fs = require('node:fs');
fs.writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper and margin controls, custom CSS and JavaScript, clicks before capture, selector waits, delay or network-idle waits, request and resource blocking, custom headers/cookies/user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Plan Included shots Price
Free 1,000 per month $0, no card
Starter 3,000 $5
Growth 15,000 $15
Pro 60,000 $39
Scale 250,000 $99
Business 1,000,000 $249

Yearly billing gives two months free, and every feature is available on every plan. Start with 1,000 free screenshots a month—no card required.

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

Frequently Asked Questions

Can I show the browser’s actual address bar with Playwright?

Not with page.screenshot(); that API captures page content. Capturing the operating-system browser window is a separate desktop-automation task and is not the documented Playwright page-screenshot path.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Should I include the URL in a visual-regression baseline?

Only if the URL itself is part of what you are testing. Otherwise, keep the image unchanged and record page.url() in metadata so route changes do not create unnecessary pixel differences.

How can I label a screenshot after a client-side route change?

Wait for the route-specific UI or other completion condition, then read page.url() and inject a fresh label. Remove any previous marker first so only the final route is shown.

Can a PDF URL header replace an image overlay?

Yes when a PDF is acceptable. Enable displayHeaderFooter and use the documented url template class; it is a different output path from PNG, JPEG, or WebP screenshots.

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

The Bottom Line

For an image file, render page.url() as a temporary overlay before page.screenshot(). Use sidecar metadata when pixels must remain untouched, or the PDF header/footer API when a paginated document is the better format.

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.