(Created on )

Puppeteer: Values must be strings. Found value '

select receives an option value that is not a string.


select receives an option value that is not a string.

Error message

Values must be strings. Found value '

How this error happens

select matches the string values of HTML options. Passing a number does not match the API’s expected type.

The snippets use an open Puppeteer page named page.

await page.setContent(
    '<select id="quantity"><option value="2">Two</option></select>'
);

await page.select(
    "#quantity",
    2
);

How to fix

Pass the option’s value as a string.

await page.select(
    "#quantity",
    "2"
);

Things to keep in mind

The argument is an option value, not its visible label or array index.

All Puppeteer errors

Keep Reading

Puppeteer Guides

All Guides →