Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check 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 Webpage Screenshot with a Custom User Agent

Set the user agent before navigation, wait for the page content you need, then save a viewport, full-page, or element screenshot with Playwright or Puppeteer.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

With Playwright, set userAgent when creating a browser context, navigate to the page, then save it with page.screenshot(). Set the user agent before navigation so it is sent with the page request. Use fullPage: true when you need the entire scrollable page rather than the visible viewport.

Capture a screenshot with Playwright

Install Playwright and its Chromium browser in your project, then save this as screenshot.js. Replace the example URL and user-agent string with values appropriate for your test. The sample user agent is illustrative, not a universal recommendation.

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 (compatible; ScreenshotCapture/1.0)',
      viewport: { width: 1280, height: 800 },
    });
    const page = await context.newPage();

    await page.goto('https://example.com', { waitUntil: 'load' });
    await page.screenshot({ path: 'page.png' });
  } finally {
    await browser.close();
  }
})();

Run it with node screenshot.js. The browser context’s userAgent and viewport options configure the request identity and visible page dimensions; page.screenshot() writes the rendered page to the specified path. See the Playwright emulation documentation, screenshot guide, and BrowserType API.

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

Capture the full page or a single element

For the entire scrollable page, change the screenshot call to:

#1 Best Overall
King&Charles Versatile Screen Roller Tool, 3pcs Different Roller+Hook+Trim
  • --- 𝐏𝐀𝐓𝐄𝐍𝐓 𝐀𝐏𝐏𝐋𝐈𝐄𝐃 𝐅𝐎𝐑---
  • 🏡【𝐊𝐢𝐧𝐠&𝐂𝐡𝐚𝐫𝐥𝐞𝐬 𝐑&𝐃 𝐈𝐧𝐭𝐞𝐧𝐭𝐢𝐨𝐧】Versatile Screen Tool - combines the core functions of multi-size roller, hidden hooks, and replaceable blades, and designed this multifunctional screen tool. It solves the problems of traditional screen installation tools with single functions, lack of safety and adaptability. It truly realizes multiple uses of one tool, making screen replacement time-saving, labor-saving, and worry-free. One-time purchase can meet your installation or replacement needs.
  • 🏡【𝟑 𝐒𝐢𝐳𝐞𝐬 𝐈𝐧𝐭𝐞𝐫𝐜𝐡𝐚𝐧𝐠𝐞𝐚𝐛𝐥𝐞 𝐑𝐨𝐥𝐥𝐞𝐫𝐬】Flexible Adaptation - In view of the differences in thickness of different window splines, we gift the roller into three specifications: Convex 0.13", Concave 0.13", and Concave 0.18", ensuring perfect matching with the mainstream rubber strip sizes on the market. Feature①: The roller is made of high-hardness plastic, which is strong and durable while avoiding the risk of traditional metal rollers scratching the screen mesh. Feature②: Metal bearing design - smoother rotation, even pressure without deviation. TIPS: you can use the provided Allen wrench to quickly disassemble and replace them.
  • 🏡【𝐁𝐥𝐚𝐝𝐞 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧-𝐑𝐞𝐭𝐫𝐚𝐜𝐭𝐚𝐛𝐥𝐞&𝐒𝐭𝐨𝐫𝐚𝐠𝐞&𝐑𝐞𝐩𝐥𝐚𝐜𝐞𝐚𝐛𝐥𝐞】①Retractable-When in use, just hold button, blade will slow rollout, convenient trimming and cutting. Blade can be retracted to prevent Accident scratches. ②Blade has double locking device: it automatically locks to prevent retraction during work and is completely closed to prevent accidental touch when retracted. Ansure your safety. ③Replaceable - A separate button is provided for changing the blades. ④Blade is made of steel-sharp, durable and won't rust. ⑤Storage-Handle has built-in blade storage design to place complimentary blade.Extra equipped 2xreplacement blades- increase service life of tool.
  • 🏡【𝐇𝐢𝐝𝐞𝐚𝐛𝐥𝐞 𝐑𝐞𝐦𝐨𝐯𝐚𝐥 𝐇𝐨𝐨𝐤】The hooks are sharp and can hook out the aged spline. The removal hook can be stored and hidden in the handle slot box. OPEN the box cover, take out the hook and insert it into the groove for use. can RETRACT after use to prevent the hook tip from scratching clothes or tool boxes. Hook made of Stainless steel material won't rust.
await page.screenshot({ path: 'page.png', fullPage: true });

For a specific element, use its locator and take a locator screenshot:

await page.locator('main').screenshot({ path: 'main.png' });

Playwright documents full-page and element screenshot workflows in its screenshot guide. Capturing a full page can produce a much taller image than the viewport.

Choose when the page is ready

The example waits for the browser’s load event. That may not be enough for content inserted later by JavaScript, while waiting for all network activity to stop may not work well on pages that keep connections open. Playwright navigation supports load, domcontentloaded, networkidle, and commit; choose based on how the target page behaves. Puppeteer’s guide uses networkidle2 in its example. These conditions are not interchangeable guarantees that every page element is visually complete.

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

Wait for a known element

If the important content appears after navigation, wait for a selector that marks its arrival before taking the screenshot:

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.locator('.report-ready').waitFor({ state: 'visible' });
await page.screenshot({ path: 'page.png' });

Use a selector that belongs to the page and represents the content you actually need. A fixed delay can be used when there is no reliable selector, but it may either wait longer than necessary or capture too early.

A custom user agent is not device emulation

Changing the user-agent string alone does not configure a mobile screen, touch input, or every other device property. A responsive page may base its layout on the viewport and other browser-context settings as well as the user agent. Configure each property relevant to the behavior you want to reproduce.

Playwright’s device presets can set a combination of user agent, screen size, viewport, and touch behavior. Its documentation notes that the Desktop Chrome preset uses a Windows-specific user-agent string; when you need the running platform’s own user agent, the documentation recommends unsetting that property. Check the preset and override only the properties needed for your test in the emulation documentation.

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.

Use Puppeteer if it is already your browser library

Puppeteer follows the same basic order: launch a browser, create a page, set its user agent, navigate, and call page.screenshot(). Its screenshot guide documents this workflow and an element-level screenshot using ElementHandle.screenshot().

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    const page = await browser.newPage();
    await page.setUserAgent('ExampleBot/1.0 (compatible; ScreenshotCapture/1.0)');
    await page.setViewport({ width: 1280, height: 800 });
    await page.goto('https://example.com', { waitUntil: 'load' });
    await page.screenshot({ path: 'page.png' });
  } finally {
    await browser.close();
  }
})();

Use the user-agent value required by the site or test rather than assuming the example identifies a real bot. Puppeteer’s documented sample uses networkidle2; the right wait condition still depends on the page. See the Puppeteer screenshot guide. Both libraries document screenshot support; there is no basis here for claiming one is universally faster or more faithful.

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. A GET request with a URL returns an image or PDF. To send a custom user agent, add the user_agent parameter to the request; see the API documentation for supported parameters and output options.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  --data-urlencode user_agent='ExampleBot/1.0 (compatible; ScreenshotCapture/1.0)' 
  -o shot.webp

The custom user-agent example is a request parameter adaptation; consult the API documentation for the exact supported parameter names and available formats. ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture, with each step optional. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers indicate the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. 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, with no card required.

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

Troubleshooting

  • The screenshot still shows the default user agent: Ensure the user agent is set on the context before creating/navigating the page in Playwright, or call page.setUserAgent() before navigation in Puppeteer. Setting it after the target request has already happened will not change that request.
  • The layout does not look like a phone: A mobile-looking user agent is not enough. Set the viewport and any other device properties the page relies on; consider using a Playwright device preset when you need a coordinated profile.
  • The screenshot is missing late-loaded content: Wait for a relevant visible selector after navigation. Reconsider the wait condition if the page renders asynchronously or maintains long-lived network connections.
  • The output is only the visible portion: Add fullPage: true to the Playwright screenshot options, or use the corresponding full-page option supported by your chosen library.
  • The element capture fails or is blank: Confirm the selector matches the intended element and that it becomes visible before capture. Puppeteer documents that its element screenshot attempts to scroll a hidden element into view; an element that is absent or never rendered still cannot be captured.
  • The browser remains open after an error: Put browser.close() in a finally block so cleanup runs even if navigation or capture throws.

FAQ

Can I use a made-up user-agent string?

You can supply a string, but it should represent the client identity your test is meant to simulate. The example above is only a placeholder and does not claim to be a recognized crawler.

Does setting the user agent prove what the server received?

It configures the browser context’s user-agent value for requests; if the test depends on server-side behavior, verify the request or resulting response in your own test environment rather than inferring it from the screenshot alone.

Quick Recap

Bestseller No. 1
King&Charles Versatile Screen Roller Tool, 3pcs Different Roller+Hook+Trim
King&Charles Versatile Screen Roller Tool, 3pcs Different Roller+Hook+Trim
--- 𝐏𝐀𝐓𝐄𝐍𝐓 𝐀𝐏𝐏𝐋𝐈𝐄𝐃 𝐅𝐎𝐑---
$12.99

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.