Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk4 min

How to Select an Option from a Dropdown with Puppeteer

Use Puppeteer’s page.select() for native HTML dropdowns, pass option values, and verify the selected values it returns. For iframes, use the frame API; custom menus need different interactions.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For a native HTML <select>, use Puppeteer’s page.select(selector, ...values) method and pass the option’s value—not necessarily its visible label. For example: await page.select('select#colors', 'blue'). It returns the option values selected and triggers input and change events. For a custom menu that only looks like a dropdown, use interactions suited to its actual markup instead.

Select an option in a native dropdown

Use a stable CSS selector for the <select>, then pass the value attribute of the option you want. Puppeteer documents this method for native select elements; it throws if the selector does not match a <select>. See the Page.select API reference.

As an Amazon Associate I earn from qualifying purchases.

const selected = await page.select('select#colors', 'blue');
console.log(selected); // ['blue']

The returned value is a string array of the values successfully selected. Await the call before asserting or continuing with actions that depend on the selection. Puppeteer triggers both input and change events once it has selected the provided options.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the option value, not its label

If the markup is <option value="blue">Ocean blue</option>, pass 'blue', not 'Ocean blue'. Inspect the page’s actual option values if a selection does not work as expected.

Choose a precise selector

Prefer an ID, name, or other stable application-owned attribute, such as select#colors or select[name="color"]. Avoid relying on a positional selector if the page structure may change.

Select one or several values

Single-select control

For a standard select, pass the one value to choose:

const selected = await page.select('select[name="color"]', 'blue');
if (!selected.includes('blue')) {
  throw new Error('The blue option was not selected');
}

Multiple-select control

For a <select multiple>, pass each desired option value as a separate argument. Puppeteer considers all supplied values:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const selected = await page.select('select#colors', 'red', 'green', 'blue');
console.log(selected);

On a single-select control, only the first supplied value is taken into account. Use the returned array when you need to verify which requested values were actually selected.

Use locators for the general interaction workflow

Puppeteer’s current page-interactions guide recommends locators for element interactions. A locator’s fill() method also supports select elements:

await page.locator('select#colors').fill('blue');

Choose page.select() when you want its explicit multi-value arguments or its returned list of selected values. Choose locator.fill() when you want to follow the guide’s locator-first interaction approach; locators automatically wait for elements to be present and in the right state. See the Puppeteer page interactions guide.

Select an option inside an iframe

A page-level selector does not target content inside a child frame. Find the relevant frame and call frame.select() on it. The frame method selects in the first matching select in that frame and throws if no matching select exists. See the Frame.select API reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const frame = page.frames().find(frame => frame.url().includes('/form'));
if (!frame) throw new Error('Form frame was not found');
const selected = await frame.select('select#colors', 'blue');

Adjust the frame-identifying condition to match your page—for example, use a known URL path or another property that reliably identifies the intended frame.

Best Value
The SQL Programming Language: .
  • Used Book in Good Condition
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Native selects and custom dropdowns are different

page.select() is for an actual HTML <select>. A custom dropdown may instead be built from buttons, listboxes, or other elements; it may not contain a native select at all. Inspect the rendered markup, then use a locator or other interaction appropriate to the widget’s real elements. Do not pass a custom menu to page.select() and expect it to behave like a native select.

Troubleshoot selection failures

  • No matching select: Check for a typo in the CSS selector and confirm the element is a real <select>. If it has not appeared yet, use a locator that waits for the element or an appropriate wait. If it belongs to an iframe, select through that frame instead.
  • The requested value is not selected: Check the option’s actual value attribute; the visible label may differ. Confirm that the intended option exists and inspect the returned array to see which values Puppeteer selected.
  • Only one value is selected: Confirm the control has the multiple attribute. On a single-select element Puppeteer considers only the first supplied value.
  • The dropdown is custom-built: Identify the menu’s actual markup and interact with its elements using locators or another suitable interaction. The select API only targets native select elements.
  • The selector works in the main page but not the embedded form: Locate the child frame and use frame.select() with a selector scoped to that frame.

Check the Puppeteer version when behavior differs

The cited Page API reference identifies Puppeteer 25.12.0, while the ElementHandle.select reference identifies 25.10.0. If the method signature or behavior differs in your project, check the documentation and API available for your installed version rather than assuming details apply to every older release. The separate ElementHandle.select reference documents that API.

Or skip the browser setup

If the goal is a clean screenshot of a page rather than an interaction test, ScreenshotNeo provides a website screenshot API and MCP server. A single request can return an image or PDF; this example saves the response as WebP. See the ScreenshotNeo documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing status.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.