Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

How to Capture a Website Screenshot with a Custom Browser User Agent

Set a custom user agent before navigation in Playwright, then choose a viewport, full-page, or element screenshot. Learn why a user-agent string is not full device emulation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With Playwright, set the desired user-agent string when you create a browser context, then navigate to the site and capture the page. Use fullPage: true to include content below the viewport. A user-agent override changes the string sent by the browser; by itself, it does not reproduce a complete phone, tablet, or other device profile.

Capture a screenshot with a custom user agent in Playwright

Install Playwright and its browser before running the script. The example uses Node.js and Chromium; replace ExampleBot/1.0 with the exact user-agent string you need. The context option must be set before navigating so the request uses the override from the start.

As an Amazon Associate I earn from qualifying purchases.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  try {
    const context = await browser.newContext({
      userAgent: 'ExampleBot/1.0'
    });
    const page = await context.newPage();
    await page.goto('https://example.com', { waitUntil: 'load' });
    await page.screenshot({ path: 'screenshot.png' });
  } finally {
    await browser.close();
  }
})();

Save the script as a JavaScript file and run it with Node.js. The output is screenshot.png in the current directory. Playwright documents context-level user-agent configuration and the navigation and screenshot APIs in its emulation documentation and Page API. This is a documentation-based example, not a claim that the code was run here.

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

Choose what part of the page to capture

Visible viewport

The default page.screenshot() captures the visible page viewport. Use this when you want to compare the initial screen or a fixed-size browser view.

#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

Entire page

Set fullPage: true to capture content beyond the viewport:

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

For pages that load images or other content only as you scroll, a full-page capture may not be enough to trigger every lazy-loaded item. Check the resulting image; if content is missing, scroll through the page before capturing or use a capture workflow that loads lazy images. Playwright documents viewport, full-page, element, and device-pixel screenshot options in its Screenshots guide and screenshots and PDF reference.

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

One element

To capture a single element, locate it and call screenshot() on the locator:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const card = page.locator('.product-card').first();
await card.screenshot({ path: 'product-card.png' });

Replace the selector with one that identifies the element on the target page. If the selector matches nothing, wait for the relevant page state or correct the selector before taking the screenshot.

Rank #3
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.

Higher-resolution output

Playwright supports device-pixel screenshot scaling. Choose the scale based on whether the image should match CSS-pixel dimensions or preserve a higher-resolution, device-pixel rendering. This affects output dimensions; it does not, on its own, change the site’s responsive layout.

When a user-agent override is not enough

A website can use more than the user-agent string to decide what to render. If your goal is to reproduce a phone or tablet layout, align the browser context’s viewport and other relevant emulation settings, such as screen dimensions, touch capability, locale, timezone, and geolocation. Playwright also provides device profiles that combine a user agent with screen-related settings. See its emulation documentation for the available context options.

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • 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

Do not assume that a changed string forces every site to return a particular version. The site may use other signals or apply its own detection and routing. Inspect the rendered page and adjust the emulation settings to match the conditions you are trying to reproduce.

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

Wait for the page state you need

The sample waits for the page’s load event, but modern pages may continue rendering or fetching content afterward. If the screenshot is incomplete, wait for a meaningful selector rather than relying on a fixed delay:

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.
await page.goto('https://example.com', { waitUntil: 'load' });
await page.locator('main').waitFor({ state: 'visible' });
await page.screenshot({ path: 'screenshot.png' });

Use a selector that represents the content your test needs. A page with an ongoing animation, delayed API response, or consent prompt may need additional handling specific to that site; a screenshot call does not guarantee that every dynamic element has settled.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • The site still looks like the original browser. Confirm that userAgent was passed to browser.newContext() before creating and navigating the page. Then inspect the rendered result; a site may not choose its layout from the user agent alone.
  • The mobile layout does not match. Set a coherent device profile or configure the viewport and relevant device-emulation properties along with the user agent. A string override alone does not replicate all device characteristics.
  • The screenshot is cut off. Use fullPage: true for the entire document, or capture a specific locator if only one component is needed.
  • Images or content are missing. Wait for the relevant element or application state. For lazy-loaded content, scroll through the page before taking a full-page capture and verify the output.
  • The script exits before saving. Keep browser cleanup in a finally block, as in the example, and check that the process has permission to write to the output directory.
  • Navigation fails or stalls. Check the URL and network access. If the site continues background activity after its load event, wait for the specific content you need rather than treating a generic load signal as proof that the page is ready.

Or skip the browser setup

ScreenshotNeo can return a screenshot with one GET request, including a custom user agent. Its cookie-banner handling accepts consent banners like a visitor and removes more than 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 response headers identify the page verdict and billing status. Its MCP server provides screenshot tools for Claude, Cursor, and other MCP clients.

For this topic, the request’s user_agent parameter supplies the override. See the ScreenshotNeo API documentation for request options and response details.

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.
curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d user_agent='ExampleBot/1.0' 
  -o shot.webp

ScreenshotNeo includes 1,000 screenshots a month free with no card; paid plans start at $5 for 3,000. Sign up for free to try it.

Frequently Asked Questions

Can I use a user-agent string to make a site show its mobile version?

Sometimes, but the string alone does not reproduce the full device environment. Configure a matching viewport and other relevant emulation settings, then verify what the site actually renders.

How do I capture only one part of a page in Playwright?

Use a locator for the target element and call its screenshot() method, rather than capturing the whole page.

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.

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

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.