DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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
browser automation

How to Capture a Cursor in Puppeteer Screenshots (The Reliable Overlay Method)

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

Short answer: Puppeteer does not document a screenshot option that composites your computer’s pointer into an image. page.mouse moves a virtual mouse and sends synthetic events, while page.screenshot() captures rendered page content. To show an arrow in the saved PNG, JPEG, or WebP, render a cursor-shaped element in the page, place it at the coordinates you want, and take the screenshot after that element is visible.

This distinction matters: an automated hover or click can happen without any pointer graphic appearing in the output. The overlay method below gives you a deterministic cursor that can be styled, positioned, hidden from interaction, and removed after capture.

What “cursor” means in Puppeteer

There are two different things developers call a cursor:

  • Virtual mouse input: Puppeteer’s page.mouse API operates in main-frame CSS pixels relative to the viewport and dispatches synthetic mouse events. It is for driving hover, click, drag, and other interactions.
  • A visible cursor in the image: an arrow, hand, ring, or highlight that is actually rendered as page content and therefore becomes part of the screenshot.

Moving the virtual mouse does not, by itself, establish that a hardware-style pointer will be composited into Page.screenshot(). The documented screenshot options cover capture and output behavior—such as fullPage, clip, type, path, and omitBackground—but do not include a “show cursor” switch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

The dependable solution: render an overlay

Create a fixed-position element, give it a cursor shape with CSS, set its coordinates, and capture the page. The element should be inside the viewport (or inside the crop passed to clip), use a high z-index, and have pointer-events: none so it cannot block the interaction you are documenting.

Complete runnable example

The following Node.js script opens a page, moves Puppeteer’s virtual mouse to a target point, injects an arrow overlay at the same CSS-pixel coordinates, waits for the browser to paint it, and saves a PNG.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  const page = await browser.newPage();
  await page.setViewport({ width: 1440, height: 900, deviceScaleFactor: 1 });
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });

  // Coordinates are viewport-relative CSS pixels, matching page.mouse.
  const x = 620;
  const y = 280;
  await page.mouse.move(x, y);

  await page.evaluate(({ x, y }) => {
    const old = document.getElementById('__puppeteer_cursor__');
    if (old) old.remove();

    const cursor = document.createElement('div');
    cursor.id = '__puppeteer_cursor__';
    cursor.setAttribute('aria-hidden', 'true');
    cursor.style.cssText = `
      position: fixed;
      left: ${x}px;
      top: ${y}px;
      width: 0;
      height: 0;
      z-index: 2147483647;
      pointer-events: none;
      transform: translate(-2px, -2px);
    `;

    // A CSS arrow made from borders, with a contrasting outline.
    cursor.innerHTML = `
      <div style="
        width: 0; height: 0;
        border-top: 18px solid #111;
        border-right: 7px solid transparent;
        transform: rotate(-35deg);
        filter: drop-shadow(1px 1px 0 #fff) drop-shadow(-1px -1px 0 #fff);
      "></div>`;
    document.documentElement.appendChild(cursor);
  }, { x, y });

  // Let the injected element reach the rendered frame.
  await page.evaluate(() => new Promise(requestAnimationFrame));
  await page.screenshot({ path: 'screenshot-with-cursor.png', type: 'png' });
  await browser.close();
})();

Replace https://example.com and the coordinates with your target. The two-pixel translation keeps the arrow’s tip close to the requested point; adjust it if your graphic’s tip is elsewhere. The exact shape is your design choice—an inline SVG, a data-URI background, or a larger spotlight can be used instead of the CSS triangle.

Use an inline SVG for a sharper cursor

SVG is useful when the screenshot is high-resolution or the cursor needs a branded outline. Keep it in the same fixed, pointer-transparent wrapper:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.evaluate(({ x, y }) => {
  const cursor = document.createElement('div');
  cursor.id = '__puppeteer_cursor__';
  cursor.setAttribute('aria-hidden', 'true');
  cursor.style.cssText = `position:fixed;left:${x}px;top:${y}px;z-index:2147483647;pointer-events:none;transform:translate(-3px,-3px);`;
  cursor.innerHTML = `
    <svg width="32" height="40" viewBox="0 0 32 40" aria-hidden="true">
      <path d="M2 2 L2 32 L10 24 L16 38 L22 35 L16 21 L28 21 Z"
        fill="white" stroke="black" stroke-width="2" stroke-linejoin="round"/>
    </svg>`;
  document.documentElement.appendChild(cursor);
}, { x: 620, y: 280 });

Keeping the cursor aligned with actions

If the screenshot documents a sequence, update the overlay whenever you move the virtual mouse. A helper keeps the two operations together:

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black
  • The next-generation optical HERO sensor delivers incredible performance and up to 10x the power efficiency over previous generations, with 400 IPS precision and up to 12,000 DPI sensitivity
  • Ultra-fast LIGHTSPEED wireless technology gives you a lag-free gaming experience, delivering incredible responsiveness and reliability with 1 ms report rate for competition-level performance
  • G305 wireless mouse boasts an incredible 250 hours of continuous gameplay on just 1 AA battery; switch to Endurance mode via Logitech G HUB software and extend battery life up to 9 months
  • Wireless does not have to mean heavy, G305 lightweight mouse provides high maneuverability coming in at only 3.4 oz thanks to efficient lightweight mechanical design and ultra-efficient battery usage
  • The durable, compact design with built-in nano receiver storage makes G305 not just a great portable desktop mouse, but also a great laptop travel companion, use with a gaming laptop and play anywhere
async function moveAndShowCursor(page, x, y) {
  await page.mouse.move(x, y);
  await page.evaluate(({ x, y }) => {
    const el = document.getElementById('__puppeteer_cursor__');
    if (!el) return;
    el.style.left = `${x}px`;
    el.style.top = `${y}px`;
  }, { x, y });
  await page.evaluate(() => new Promise(requestAnimationFrame));
}

await moveAndShowCursor(page, 420, 190);
await page.screenshot({ path: 'hover-state.png' });

await page.mouse.click(420, 190);
await page.waitForNetworkIdle({ idleTime: 500, timeout: 5000 }).catch(() => {});
await page.screenshot({ path: 'after-click.png' });

The cursor graphic is not a Puppeteer feature; it is application content that you inject for the capture. If the page re-renders its root, a framework navigation replaces the document, or a full reload occurs, inject the overlay again before the next screenshot.

Choosing coordinates, viewport, and crop

Viewport and device scale

page.mouse and CSS positioning use CSS pixels. Set the viewport before navigation and use the same coordinate system for both calls. A deviceScaleFactor greater than 1 increases output pixel density but does not change the CSS coordinates you pass to page.mouse.move() or left/top.

await page.setViewport({
  width: 1280,
  height: 800,
  deviceScaleFactor: 2
});

Full-page screenshots

With fullPage: true, the browser captures content beyond the visible viewport. A position: fixed cursor remains anchored to the viewport’s visible origin, not to an arbitrary point farther down the stitched page. For a cursor over content below the fold, scroll first, position the overlay after scrolling, and capture that viewport; or use an absolutely positioned marker in the document and calculate its location after layout.

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

Clipped screenshots

When using clip, the cursor must fall inside the clip rectangle to appear. Remember that clip.x and clip.y describe page coordinates while the overlay’s position: fixed coordinates are viewport-relative. Capture without a clip while debugging alignment, then add the crop.

Element screenshots

Puppeteer also supports ElementHandle.screenshot() when only one element is needed. Inject the cursor into that element (or ensure it is inside the element’s stacking context) before calling the element screenshot. A fixed overlay attached to document.documentElement may be outside the element’s capture region.

Rank #3
Sale
Logitech M185 Compact Ambidextrous Wireless Mouse with Rubber Grips - Blue
  • Compact Mouse: With a comfortable and contoured shape, this Logitech ambidextrous wireless mouse feels great in either right or left hand and is far superior to a touchpad
  • Durable and Reliable: This USB wireless mouse features a line-by-line scroll wheel, up to 1 year of battery life (2) thanks to a smart sleep mode function, and comes with the included AA battery
  • Universal Compatibility: Your Logitech mouse works with your Windows PC, Mac, or laptop, so no matter what type of computer you own today or buy tomorrow your mouse will be compatible
  • Plug and Play Simplicity: Just plug in the tiny nano USB receiver and start working in seconds with a strong, reliable connection to your wireless computer mouse up to 33 feet / 10 m (5)
  • Better than touchpad: Get more done by adding M185 to your laptop; according to a recent study, laptop users who chose this mouse over a touchpad were 50% more productive (3) and worked 30% faster (4)

Waiting for a reliable frame

Adding a DOM node and immediately taking a screenshot can race the browser’s paint cycle. Waiting for one animation frame is usually enough for the injected style and markup to be rendered:

await page.evaluate(() => new Promise(requestAnimationFrame));

For pages with fonts, animations, lazy images, or transitions, also wait for the state you intend to show. Prefer a deterministic selector or application-ready signal over a long arbitrary delay. If an animation moves the target, pause it or take the screenshot after it reaches a known state.

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

Making the overlay visible on any background

  • Use a dark fill with a light outline, or the reverse, so the cursor remains legible on both light and dark regions.
  • Give it a high z-index, but remember that a transformed ancestor can create a separate stacking context. Appending to document.documentElement avoids most component-level stacking conflicts.
  • Set aria-hidden="true" because the marker is visual annotation, not page content for assistive technology.
  • Use pointer-events: none so the marker never intercepts hover or click events.
  • Remove the marker before producing a clean, cursor-free screenshot: await page.evaluate(() => document.getElementById('__puppeteer_cursor__')?.remove());

Common failures and fixes

No cursor appears

Cause: the overlay was never injected, was removed during navigation, or the screenshot was taken before it painted. Fix: inject after the final navigation, verify document.getElementById('__puppeteer_cursor__') exists, wait for requestAnimationFrame, and check that the coordinates are inside the viewport.

The arrow is offset from the intended target

Cause: the arrow’s visual tip is not its element origin, or page scrolling was not considered. Fix: adjust the CSS translation so the tip, rather than the wrapper’s top-left corner, lands on the target. Keep one coordinate convention and log page.viewport() while debugging.

The marker is behind the page

Cause: a stacking context or an unusually high application layer hides it. Fix: append it to the document root, use a high z-index, and avoid placing it inside an ancestor with overflow: hidden or a transform that clips it.

Rank #4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
  • Computer mouse for easily navigating a computer interface; click, scroll, and more
  • USB-A wired connection; if existing device only supports USB-C, an additional adapter will be required
  • High-definition (1000 dpi) optical tracking ensures responsive cursor control for precise tracking and easy text selection
  • 3 buttons offer effortless fingertip control
  • Plug-and-go ready for instant use

Hover styling does not activate

Cause: the visible graphic is separate from the virtual mouse, or the coordinates are wrong. Fix: call page.mouse.move(x, y) first, then add or move the overlay at the same coordinates. The overlay itself does not generate pointer events.

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

The cursor disappears in a full-page capture

Cause: a fixed marker is tied to the viewport while the full-page image includes a larger document. Fix: capture the viewport where the cursor is needed, scroll to the target before capture, or use a document-positioned marker whose location is calculated for the desired scroll position.

The screenshot contains a stale cursor after navigation

Cause: the old document was replaced, so the injected element no longer exists—or a new page retained a marker with an old coordinate. Fix: run the injection helper after every navigation and update its position immediately before each capture.

What Puppeteer can and cannot capture

Goal Use What appears in the saved image
Trigger hover or click page.mouse.move(), page.mouse.click() Page state changes caused by synthetic events; no documented pointer graphic
Show an arrow at a known point Rendered HTML, CSS, or SVG overlay The overlay, because it is page content
Capture the page page.screenshot() Rendered page pixels subject to screenshot options
Capture one component elementHandle.screenshot() The selected element’s capture region, including an overlay inside that region
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and maintenance

The overlay itself is tiny; the expensive parts of a screenshot job are normally page startup, navigation, JavaScript execution, fonts, images, and full-page rasterization. Reuse a browser process when capturing many pages, but create an isolated page for each URL and remove the marker when it is no longer needed.

Use a stable readiness condition, set navigation and screenshot timeouts appropriate to the site, and record the viewport, scroll position, target coordinates, and output type alongside each image. If a page has a cookie dialog, chat launcher, or animation covering the target, handle that state before placing the marker; the cursor overlay does not make obstructing content disappear.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Acer Wireless Mouse for Laptop, 2.4GHz Computer Mouse 3 Adjustable 1600 DPI
  • 【Plug and Play for Home/Office/School】The wireless computer mouse features 2.4GHz connectivity, delivering a stable, interference-free connection up to 32ft. Designed for 𝐦𝐞𝐝𝐢𝐮𝐦 𝐭𝐨 𝐥𝐚𝐫𝐠𝐞 𝐬𝐢𝐳𝐞𝐝 𝐡𝐚𝐧𝐝𝐬, it ensures comfortable use all day. Simply plug in the USB-A receiver for instant pairing—no drivers needed. 📌📌 If the mouse isn’t suitable, place the USB receiver in the battery compartment and return both.
  • 【3 Levels Adjustable DPI】This travel USB mouse offers 3 adjustable DPI settings (800, 1200, 1600), allowing you to customize sensitivity for precise design work. Effortlessly switch to match your task and elevate your productivity. 📌 Please remove the film at the bottom of the mouse before use.
  • 【Effortless Browsing】Equipped with forward and backward buttons, this computer mice streamlines your workflow, making it easy to navigate through web pages and files with a simple click. 📌Side button does not work on Mac.
  • 【Visible Indicator Light】 The pc mouse features a visual indicator for DPI levels and low battery alerts. The red light flashes once for 800 DPI, twice for 1200 DPI, and three times for 1600 DPI. When the battery level is below 10%, the light flashes red until the mouse is completely out of power.
  • 【Click to Wake】With smart sleep mode, it saves power by standby after 10 inactive minutes, just 2-3 clicks to wake. This efficient design delivers 3x longer battery life than motion-wake mice. Engineered for durability, its buttons and scroll wheel are tested for 10 million clicks, ensuring long-term reliability and consistent performance.

Puppeteer APIs and option names can change. The current reference pages used for this guidance identify version 25.12.0; check the documentation for the version installed in your project before relying on a particular option.

Or skip the browser setup

If you need a rendered website image rather than a custom Puppeteer workflow, ScreenshotNeo provides a single HTTP request for PNG, JPEG, WebP, or PDF output. It removes cookie-consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

For a direct capture, see the ScreenshotNeo documentation and run:

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

The service supports full-page captures with lazy images, CSS-selector element shots, dark mode, device presets or custom viewports, retina scale, PDF controls, custom CSS and JavaScript, click and wait actions, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs are accepted to ease migration.

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.

Plans include 1,000 screenshots per month free without a card; paid plans start at $5 for 3,000 screenshots. Other listed plans are Growth at $15 for 15,000, Pro at $39 for 60,000, Scale at $99 for 250,000, and Business at $249 for 1,000,000. Yearly billing provides two months free, and every feature is available on every plan.

Create a free ScreenshotNeo account to use the 1,000 monthly screenshots without a card.

Frequently Asked Questions

Can Puppeteer capture the operating-system mouse pointer?

Not through the documented page screenshot API. The reliable approach is to render a pointer-shaped element in the page before calling page.screenshot().

Should I use a real USB mouse for this?

No. Puppeteer’s page.mouse is a virtual input API; physical pointing hardware is unrelated to the screenshot output.

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

Will an injected cursor appear in a PDF generated by Puppeteer?

It can appear only if the PDF rendering includes that page content at the time of generation. Treat the marker as ordinary DOM content and verify its position and print styling for the specific PDF workflow.

Quick Recap

SaleBestseller No. 1
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Logitech M185 Compact Ambidextrous 2.4 GHz Wireless Mouse - Swift Grey
Product carbon footprint: 3.97 kg CO2e; Contoured shape: Gives you more comfort and control
$14.90
SaleBestseller No. 3
Bestseller No. 4
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Amazon Basics 3-Button USB Wired Mouse with Responsive Tracking, Plug & Play, Compatible with Windows and Mac, Black
Computer mouse for easily navigating a computer interface; click, scroll, and more; 3 buttons offer effortless fingertip control
$9.70

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.