(Created on )

Puppeteer: At least one query method must be defined.

The browser-side custom selector has neither queryOne nor queryAll.


The browser-side custom selector has neither queryOne nor queryAll.

Error message

At least one query method must be defined.

How this error happens

The browser-side custom selector registry cannot build a handler without either query method. A malformed handler is the relevant failing configuration.

The snippets use the imported Puppeteer class for its static query-handler methods. The fix uses the same import.

import {
    Puppeteer,
} from "puppeteer";

Puppeteer.registerCustomQueryHandler(
    "custom",
    {}
);

The public registration normally rejects this earlier with “At least one query method must be implemented.” The message on this page comes from the injected browser-side check; the snippet illustrates the bad configuration, not a guaranteed reproduction of that later check.

How to fix

Provide a real query function and register it through the public API.

Puppeteer.registerCustomQueryHandler(
    "custom",
    {
        queryOne: (root, selector) => {
            return root.querySelector(selector);
        },
    }
);

Things to keep in mind

If this browser-side message appears despite a valid public registration, isolate the plugin or injected selector code. Do not modify Puppeteer’s private selector registry.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →