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 DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

How to Select an Option in a Puppeteer Frame

Use the Puppeteer Frame containing the dropdown and call frame.select() with the select selector and option value. Learn how to find the frame, handle multiple selects, and troubleshoot failures.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To select a dropdown option inside an iframe, get the Puppeteer Frame that contains the <select>, then call frame.select(selector, optionValue). The arguments are option values—not the visible labels. For example: await frame.select('select#colors', 'blue').

Find the frame that contains the select

Puppeteer evaluates frame-scoped operations in the receiver frame’s context. A selector run against the main frame will not find a control inside a child iframe. Pages expose their frame tree through page.frames(), and each frame also exposes its child frames.

As an Amazon Associate I earn from qualifying purchases.

For example, locate a frame by a stable URL fragment, then select the option:

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('/preferences'));
if (!frame) throw new Error('Preferences frame not found');

const selectedValues = await frame.select('select#colors', 'blue');
console.log(selectedValues);

Use an identity that fits the page, such as a stable URL, frame name, or the associated iframe’s identity. The URL-fragment check above is only an example; avoid relying on a fragment that can change between runs. Puppeteer’s Frame API reference documents frame identity and the frame tree.

Select by option value

Frame.select() takes a CSS selector for a <select> and one or more option values. It acts on the first matching select in that frame, and its returned array contains the values it successfully selected. The current API reference marks this method for Puppeteer 25.12.0; check the reference for the Puppeteer version installed in your project.

const selectedValues = await frame.select('select#colors', 'blue');

If the markup is <option value="blue">Blue</option>, pass 'blue', not 'Blue'. Confirm the option’s actual value when a selection does not behave as expected.

Handle single-select and multiple-select controls

Single-select

Pass the value of the option you want:

await frame.select('select#colors', 'blue');

Multiple-select

For a <select multiple>, pass each desired value as an additional argument:

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

Puppeteer considers all supplied values for a multiple-select. If the element is not a multiple-select, only the first supplied value is considered.

Choose between Frame.select and a locator

Use frame.select() when you know the option value and want the direct selection API, including passing several values to a multiple-select. Puppeteer’s interaction guide also recommends locators for common interactions: locators can wait for an element to be present and ready, and Locator.fill() supports select elements.

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

A frame locator still runs in the frame it belongs to. Choose the approach based on the interaction you need: direct value selection, especially for multiple values, or locator readiness behavior.

Troubleshoot a selection that fails

  • No matching select: Frame.select() throws if it finds no matching <select>. Check both the selector and that you called it on the frame containing the control.
  • Wrong frame: page.select() is shorthand for page.mainFrame().select(). For an iframe, call select() on that child frame instead.
  • Wrong option value: The method accepts option values, not display text. Inspect the page’s markup or the option values and pass the exact value.
  • Several selects match: The method acts on the first matching select. Narrow the selector so it identifies the intended control.
  • Frame lookup returns nothing: Verify the frame identity against the page’s current frame tree and use a stable URL, name, or iframe identity. Do not assume a control belongs to the main frame.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot of the page rather than to change a form control, ScreenshotNeo can return an image or PDF with one GET request. It accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients.

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

cURL:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo has a free plan with 1,000 shots per month and no card required; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card.

For frame selection, however, use Puppeteer’s frame API: a screenshot API captures a page; it does not select a dropdown option.

Frequently Asked Questions

Can I pass the visible option label to Puppeteer’s select method?

Pass the option’s value attribute. The visible label may differ from that value.

Does page.select() work for a dropdown inside an iframe?

No. It operates on the main frame. Use the child Frame containing the dropdown.

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

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
Windows Errors? Fix Them Before They SpreadFree repair scan

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.