(Created on )

Puppeteer: Custom query handler names may only contain [a-zA-Z]

A custom handler name contains characters outside ASCII letters.


A custom handler name contains characters outside ASCII letters.

Error message

Custom query handler names may only contain [a-zA-Z]

How this error happens

Custom handler names may contain ASCII letters only. Digits, dashes and underscores are rejected.

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(
    "by-test-id",
    {
        queryOne: (root, selector) => {
            return root.querySelector(selector);
        },
    }
);

How to fix

Choose an alphabetic name and use that name consistently in selectors.

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

Things to keep in mind

The handler’s implementation should match its intended semantics; this simple example delegates to CSS.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →