October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Use Puppeteer’s Mouse API for Browser Automation

A practical guide to Puppeteer’s coordinate-based mouse API, including clicks, drag paths, wheel events, locators, navigation waits, and its text-selection limitation.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use page.mouse when an automation needs pointer input at specific viewport coordinates: move, click, press and drag, or send wheel input. For ordinary interaction with a known page element, Puppeteer recommends a locator instead. Mouse input is synthetic, and the API cannot drag-select text like a physical mouse.

What page.mouse does

Each Puppeteer Page exposes its own Mouse instance as page.mouse. It sends pointer events by coordinate rather than finding a target by selector. Coordinates are main-frame CSS pixels relative to the viewport’s top-left corner; they are not document coordinates. Use the instance on the page rather than constructing a Mouse yourself. The official documentation checked for this guide showed Puppeteer 25.12.0 on key pages; API page labels were not uniform, so check method signatures against the version installed in your project. Puppeteer Mouse class · Page class

As an Amazon Associate I earn from qualifying purchases.

Set up a page before sending mouse input

The following CommonJS example launches Chromium, opens a page, and performs a coordinate click. It assumes Puppeteer is installed in the project and a usable browser is available through its installation or configuration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });

    // Coordinates are CSS pixels from the viewport's top-left corner.
    await page.mouse.click(120, 80);
  } finally {
    await browser.close();
  }
})();

Replace the example URL and coordinates with the target page and a point in its current viewport. If the target is an element you can identify in the DOM, use a locator instead of guessing its coordinates.

#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)

Click a coordinate

await page.mouse.click(120, 80);

click(x, y, options) is a convenience sequence: Puppeteer moves the pointer to the coordinate, presses the selected button, and releases it. The left button is the default; the documented button choices are left, right, middle, back, and forward. Use coordinate clicks when the point itself is the intended target, such as a canvas or a custom interface with no suitable element locator. Mouse.click() · MouseButton · MouseOptions

Move, press, and release for a drag path

await page.mouse.move(startX, startY);
await page.mouse.down();
await page.mouse.move(endX, endY);
await page.mouse.up();

These lower-level calls let you hold a button while changing coordinates, which is useful for interfaces that respond to pointer paths. move() returns a promise and accepts movement options; steps controls the number of movements between the previous and new positions and defaults to 1. The class reference also documents drag, drag-and-drop, drag-enter, drag-over, and drop operations for purpose-built sequences. These calls dispatch synthetic events; they do not promise to reproduce every operating-system mouse behavior. Mouse.move() · MouseMoveOptions

Rank #2
Sale
Logitech G305 Lightspeed Wireless Gaming Mouse - Black | 12,000 DPI, Lightweight, 6 Programmable Buttons, 250h Battery, On-Board Memory, Compatible with PC and Mac
  • 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

Text selection is a limitation

Puppeteer’s Mouse API documentation states: “The mouse events trigger synthetic MouseEvents. This means that it does not fully replicate the functionality of what a normal user would be able to do with their mouse.” In particular, dragging with page.mouse cannot select text. To create a selection between DOM nodes, use the document or shadow-root Selection API with a Range; that is a DOM operation, not a simulated mouse gesture. For copying selected content, Puppeteer points to the clipboard API, whose use depends on clipboard permissions and tab focus. Mouse class limitations and selection example

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

Send wheel input

await page.mouse.move(centerX, centerY);
await page.mouse.wheel({ deltaY: -100 });

Position the pointer over the relevant area first. wheel() dispatches a mousewheel event; a negative deltaY is used in the official example to demonstrate zooming. A wheel event does not guarantee ordinary document scrolling: the page’s handlers and browser behavior determine its effect. Mouse.wheel()

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)

Choose between mouse coordinates and a locator

Approach How you specify the target What it checks or controls Best fit
page.mouse Viewport coordinates You control pointer position and the sequence of input; it does not first identify an element. Custom pointer paths, canvas interactions, or cases where coordinates are specifically required.
page.locator(...) A selector or other locator target Before acting, Puppeteer checks viewport presence, visibility, enabled state, and bounding-box stability over consecutive animation frames. Routine interaction with a page element.

Puppeteer’s interactions guide recommends locators for finding and interacting with elements. A locator click, for example, avoids manually calculating the target’s current coordinates. For a compatibility option, page.click(selector) finds the first matching element, scrolls it into view if necessary, then uses Page.mouse to click its center. It rejects if no match exists. Page interactions guide · Page.click()

Wait reliably when a click navigates

If a selector click is expected to trigger navigation, start the navigation wait and click together. This avoids the race in which navigation begins before the wait is registered.

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
const [response] = await Promise.all([
  page.waitForNavigation(),
  page.click('a.next'),
]);

Choose navigation-wait options appropriate to the application; the key is registering the wait in the same Promise.all as the click. Page.click() navigation example

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

Common problems and fixes

  • The click lands on the wrong place: Coordinates are viewport-relative CSS pixels. Re-check the viewport size and target’s current location rather than treating coordinates as page-wide document positions. For a DOM element, switch to a locator.
  • A drag gesture does not select text: This is a documented limitation of synthetic mouse events. Use a DOM Range and Selection API for programmatic selection instead.
  • The page scrolls or zooms unexpectedly—or not at all: Wheel input is delivered at the pointer location, and page handlers determine the outcome. Move to the intended area, then inspect the page’s wheel behavior and event handling.
  • A selector click fails because the element is absent: page.click(selector) rejects when no matching element exists. Check the selector and whether the page has loaded the target; a locator is the recommended element-oriented interaction path.
  • A click-triggered navigation is missed: Register waitForNavigation() alongside the click in Promise.all, rather than waiting only after clicking.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If the task is to capture a page rather than automate a pointer interaction, ScreenshotNeo offers a one-request screenshot API. This does not replace Puppeteer for interactive workflows; it returns a screenshot or PDF from a URL.

Best Value
Sale
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.

cURL example and API documentation:

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

ScreenshotNeo removes supported cookie and consent banners, newsletter popups, and chat widgets before capture; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers identifying the page verdict and billing status. Its MCP server provides screenshot and PDF tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000. Sign up for the free plan.

Frequently Asked Questions

Can I construct a Puppeteer Mouse directly?

Use the Mouse instance exposed by a Page as page.mouse; the constructor is internal.

Can Puppeteer’s mouse API produce physical mouse input?

No. The API dispatches synthetic mouse events and does not fully reproduce physical mouse functionality.

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.

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.85
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.

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
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.