Node is either not visible or not an HTMLElement
How to fix the Puppeteer error: Node is either not visible or not an HTMLElement
Error
Node is either not visible or not an HTMLElement
What it means
Puppeteer raised this from its element handling code. In practice, it usually means your script reached a browser, page, frame, element, or option state that the API cannot use safely.
How to fix it
- Confirm the selector matches an element in the same frame where you are querying.
- Wait for the element to be attached and visible before acting on it.
- Re-query the element after DOM updates instead of reusing an old
ElementHandle.
Minimal guard
try {
// Run the Puppeteer operation that triggers this error.
} catch (error) {
if (error instanceof Error && error.message.includes("Node is either not visible or not an HTM")) {
// Apply the fix above, then retry or fail with a clearer message.
}
throw error;
}