(Created on )

Puppeteer: Cannot send more than 1 character.

sendCharacter receives more than one Unicode code point.


sendCharacter receives more than one Unicode code point.

Error message

Cannot send more than 1 character.

How this error happens

In WebDriver BiDi, sendCharacter inserts one Unicode code point. Passing a word asks the API to insert more than one character in a single call.

The snippets use an open Puppeteer page named page.

await page.setContent(
    '<input id="name">'
);

await page.focus("#name");

await page.keyboard.sendCharacter(
    "Ada"
);

How to fix

Use keyboard.type for a string. Keep sendCharacter for a single character.

await page.keyboard.type(
    "Ada"
);

Things to keep in mind

JavaScript string length counts UTF-16 code units. A single emoji can occupy two code units but still be one Unicode code point.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →