Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

Puppeteer click() fails because the element has no usable box

Your error

Error: Node is either not clickable or not an Element2 more lines it can show

Fix it fast

Most common cause, 1 of 3

The selector's first match is a hidden copy of the element

Make the selector match only the element people click: scope it to the visible container, use a test attribute, or select by text with Puppeteer's ::-p-text() selector.

Fix
// a selector that matches one element
await page.locator('[data-testid="pay-now"]').click();

// or choose the visible one among several matches
const handles = await page.$$('#checkout button.pay');
for (const h of handles) {
  if (await h.isVisible()) { await h.click(); break; }
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

Puppeteer throws Node is either not clickable or not an Element (old releases: not visible or not an HTMLElement) when the element has no clickable box: the selector hit a hidden copy, the element is not shown yet, or it has zero size. Use a locator, which waits for a visible, stable element, or click what users see (Puppeteer 25).

  • Applies to Puppeteer 25.18, Node.js 22, 24 and 26
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print every element the selector matches, with Puppeteer's own visibility verdict and box, right where the click fails. Several matches with a null box first is cause 1. A single match that is hidden now but fine a second later is cause 2. A box that exists but has width or height 0 is cause 3.

Run this first
const handles = await page.$$('#checkout button.pay');
for (const [i, h] of handles.entries()) {
  console.log(i, await h.isVisible(), await h.boundingBox());
}

Then find the line you see in this list and open its fix:

  1. 1The selector's first match is a hidden copy of the elementpage.$$ returns two or more handles; the first logs false and null, a later one logs true and a real box
  2. 2The element is in the DOM but not displayed yet when click() runsOne match; isVisible() is false at the failing moment, and the same click works after a short delay or on a retry
  3. 3The element is rendered with zero width or heightboundingBox() returns an object, not null, but width or height is 0; isVisible() is false

What does the error look like?

  • Error: Node is either not clickable or not an Element
  • Error: Node is either not clickable or not an HTMLElement
  • Error: Node is either not visible or not an HTMLElement

Cause 1 of 3

The selector's first match is a hidden copy of the element

You seepage.$$ returns two or more handles; the first logs false and null, a later one logs true and a real box

Check

click() and hover() call clickablePoint(), which throws Node is either not clickable or not an Element when the element has no client rects of at least 1x1 pixel. page.$ returns the first element that matches, and a responsive page may keep a second copy of the same button (a mobile menu or a closed drawer) under display: none, ahead of the visible one. boundingBox() then returns null, which the docs say means the element is not part of the layout.

Check
console.log(await page.$$eval('#checkout button.pay', els => els.length));

Fix

Make the selector match only the element people click: scope it to the visible container, use a test attribute, or select by text with Puppeteer's ::-p-text() selector. If the markup cannot change, pick the first handle that Puppeteer reports as visible.

Fix
// a selector that matches one element
await page.locator('[data-testid="pay-now"]').click();

// or choose the visible one among several matches
const handles = await page.$$('#checkout button.pay');
for (const h of handles) {
  if (await h.isVisible()) { await h.click(); break; }
}

Verify

The diagnostic loop now prints a single match with true and a box, and the click goes through.

Verify
console.log(await page.$$eval('[data-testid="pay-now"]', els => els.length)); // 1

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 2 of 3

The element is in the DOM but not displayed yet when click() runs

You seeOne match; isVisible() is false at the failing moment, and the same click works after a short delay or on a retry

Check

An element can exist in the DOM before the app shows it: a modal that opens with an animation, a button revealed after data loads, or a form step that is still display: none. page.$ and waitForSelector without options return as soon as the node exists, so the click arrives while it has no box. waitForSelector only waits for visibility when visible: true is passed, and that option defaults to false.

Check
console.log(await (await page.$('#confirm')).isVisible());

Fix

Use a locator. Puppeteer's locator click waits for the element to be in the viewport, visible, enabled and to keep a stable bounding box for two animation frames, then clicks. With the older handle API, wait with visible: true first.

Fix
// preferred: the locator waits for all preconditions
await page.locator('#confirm').click();

// handle API: wait until it is visible, then click
const confirm = await page.waitForSelector('#confirm', { visible: true });
await confirm.click();

Verify

Repeat the run five times, also on the slower CI runner. Each run clicks through with no added sleep.

Verify
for i in 1 2 3 4 5; do node scripts/checkout.mjs || break; done

Confirmed by pptr.dev

Did this fix it?

Cause 3 of 3

The element is rendered with zero width or height

You seeboundingBox() returns an object, not null, but width or height is 0; isVisible() is false

Check

Puppeteer looks for a client rect that is at least 1 pixel wide and 1 pixel high, and its isVisible() check requires a non-empty bounding rect. A custom checkbox or radio button whose real input is styled to width: 0 or height: 0 behind a decorated label is the typical case: users see a control, yet the element the selector picks has no area to aim at.

Check
console.log(await (await page.$('input#terms')).boundingBox());

Fix

Click the element that carries the visible area, usually the label or wrapper. When the zero-size input must receive the action, call the DOM method click() on it inside the page; it simulates a mouse click by firing the element's click event, with no coordinates needed (a disabled input ignores it).

Fix
// click what users actually see
await page.locator('label[for="terms"]').click();

// or trigger the input itself without mouse coordinates
const terms = await page.$('input#terms');
await terms.evaluate(el => el.click());

Verify

The input changes state after the action.

Verify
console.log(await page.$eval('input#terms', el => el.checked)); // true

Confirmed by pptr.dev

Did this fix it?

How do I stop it coming back?

  • Prefer page.locator(...).click() over page.$ followed by click(); the locator retries until the element is visible, enabled and has a stable box.
  • Add data-testid attributes to the buttons your scripts drive, so one selector maps to one element across desktop and mobile layouts.
  • In the catch block of a failing click, log isVisible() and boundingBox() for the handle, so a CI failure shows which of the three cases happened.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: TaxiDex, Workforce.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.