For a normal text field, use a locator and fill():
await page.locator('input[name="email"]').fill('person@example.com');
This is Puppeteer’s current, wait-aware approach for assigning values to inputs, textareas, selects, and contenteditable elements. Use keyboard APIs instead when the page specifically depends on per-character key events.
Choose the interaction that matches your goal
Puppeteer offers several ways to put data into a form. The right choice depends on whether you need to set a control’s value, reproduce keyboard activity, or work with an element handle you already obtained.
| Goal | Recommended API | What it does |
|---|---|---|
| Set an ordinary form value | locator.fill(value) |
Waits for the element to be present and ready, then fills the supported control. |
| Trigger keyboard behavior for every character | locator.click(), then keyboard.type(text) |
Focuses the control and emits keyboard/input events for each character. |
| Send a special key | keyboard.press('Enter') |
Sends a key such as Enter after the intended control is focused. |
| Maintain older page-level code | page.type(selector, text) |
A lower-level compatibility API that accepts a selector and optional per-character delay. |
| Work with an existing element handle | elementHandle.type(text) |
Focuses that handle and sends key events character by character. |
For new, straightforward code, start with a specific locator and fill(). Locators handle the wait for presence and action readiness, reducing race conditions caused by typing immediately after navigation.
Minimal working example
Install Puppeteer in a Node.js project, then run this example. Replace the URL and selector with those used by your form.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com/form');
await page.locator('input[name="email"]').fill('person@example.com');
} finally {
await browser.close();
}
The try/finally ensures Chromium closes even if navigation or filling fails. In a real test, follow the fill with an assertion, submission, or another interaction that proves the value was accepted.
Write a selector that identifies the intended field
A selector must identify the control you mean, not merely any input on the page. A page with email, password, search, and hidden fields can make 'input' dangerously broad.
Stable CSS attributes
Prefer a unique ID or name that is part of the form contract:
await page.locator('#email').fill('person@example.com');
await page.locator('input[name="email"]').fill('person@example.com');
await page.locator('textarea[name="message"]').fill('Hello from Puppeteer');
Data attributes intended for automation can also be stable:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
await page.locator('[data-testid="billing-email"]').fill('billing@example.com');
Accessible-name selection
When a properly associated label is available, select by the field’s accessible name. This keeps the test close to what a user sees and avoids depending on generated CSS classes. Use the locator syntax supported by the Puppeteer version installed in your project; the official getting-started pattern demonstrates accessible-name selection.
await page.getByLabel('Email address').fill('person@example.com');
If your project version does not expose that convenience method, use a CSS selector for the associated id or name. Do not guess at a selector: inspect the rendered element and confirm it is unique.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Confirm the target before filling
When a selector may match more than one element, make it narrower or assert the expected count before acting:
const email = page.locator('form#signup input[name="email"]');
await email.fill('person@example.com');
Scoping to the relevant form prevents a similarly named field in a newsletter widget or modal from receiving the value.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →What fill() supports
fill() chooses the appropriate runtime behavior for common controls. It supports text inputs, textareas, selects, and contenteditable elements. For checkbox-like controls, radio buttons, and switches, pass a boolean rather than text.
Text input and textarea
await page.locator('input[name="firstName"]').fill('Avery');
await page.locator('textarea[name="comment"]').fill('Please call me tomorrow.');
Select controls
Use the value expected by the option, not necessarily its visible label:
await page.locator('select[name="country"]').fill('US');
If the site uses a custom JavaScript dropdown rather than a native <select>, it is not a select control from Puppeteer’s perspective. Click the widget and choose its option using the widget’s accessible role, text, or stable attributes.
Contenteditable regions
await page.locator('[contenteditable="true"]').fill('Formatted editor content');
Rich-text editors can add their own event and formatting requirements. If the editor does not react to fill(), use its visible editing surface and keyboard workflow, or interact with the editor’s documented application API.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Checkboxes, radios, and switches
await page.locator('input[type="checkbox"][name="terms"]').fill(true);
await page.locator('input[type="checkbox"][name="marketing"]').fill(false);
A boolean expresses the desired checked state. It is clearer and less error-prone than trying to type a string into a non-text control.
When keyboard typing is the better choice
fill() is value assignment. Some interfaces listen for keyboard activity on every character—for example, an autocomplete menu, a masked input, or code that updates only after an input event sequence. Focus the intended element and use the keyboard API in that case.
const search = page.locator('input[name="search"]');
await search.click();
await page.keyboard.type('puppeteer');
await page.keyboard.press('Enter');
Puppeteer documents a keydown, keypress/input, and keyup sequence for each character typed. keyboard.press() is the appropriate call for special keys such as Enter. Keep the click immediately before typing so focus cannot drift to another control.
Typing with a delay
For code that must mimic a slower user or expose timing-dependent UI, pass a delay to the keyboard type operation:
await search.click();
await page.keyboard.type('puppeteer', {delay: 75});
Use delays only when the behavior under test needs them; they make suites slower and do not improve ordinary value assignment.
Legacy and element-handle alternatives
page.type()
Existing suites may use the page-level method:
await page.type('input[name="email"]', 'person@example.com');
It remains documented and supports a per-character delay, but current interaction guidance positions page-level methods as lower-level compatibility APIs. For new code, prefer a locator so waiting and interaction are expressed together.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
ElementHandle.type()
If another operation already produced an element handle, you can type through it:
const input = await page.$('input[name="email"]');
if (!input) throw new Error('Email input was not found');
await input.type('person@example.com');
Handles can become stale after a page re-render. Locators are generally easier to maintain because they resolve the element when the action runs.
Complete form example with validation and submission
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch({headless: true});
try {
const page = await browser.newPage();
await page.goto('https://example.com/signup', {waitUntil: 'networkidle2'});
const email = page.locator('form#signup input[name="email"]');
const password = page.locator('form#signup input[name="password"]');
const terms = page.locator('form#signup input[name="terms"]');
await email.fill('person@example.com');
await password.fill('correct-horse-battery-staple');
await terms.fill(true);
await page.locator('form#signup button[type="submit"]').click();
await page.waitForNavigation({waitUntil: 'networkidle2'});
} finally {
await browser.close();
}
Choose navigation waiting that matches the application. Single-page apps may not navigate at all; in that case wait for a success locator, URL change, or response instead of unconditionally calling waitForNavigation().
Troubleshooting common failures
“No element found” or a timeout
- Cause: The selector is wrong, the form is inside an iframe, or the page has not reached the state that renders the field.
- Fix: Inspect the final DOM, use a stable ID/name or accessible label, wait for the relevant UI state, and switch to the frame containing the form before creating the locator.
The wrong field receives the value
- Cause: A broad selector such as
inputmatches several controls. - Fix: Scope the locator to the correct form and add a unique name, ID, or test attribute.
The value appears but the application does not react
- Cause: The application expects keyboard-driven events, a custom widget interaction, or a framework-specific event sequence.
- Fix: Focus the element and use
keyboard.type(); for a custom select or editor, interact with its visible widget rather than treating it as a native control.
Typing goes to the wrong place
- Cause: Focus changed between locating the field and keyboard input.
- Fix: Call
locator.click()immediately beforekeyboard.type(), and avoid unrelated asynchronous actions between them.
The control is inside an iframe
Page locators cannot cross frame boundaries. Obtain the relevant frame, then create the locator from that frame:
const frame = page.frames().find(f => f.url().includes('/checkout'));
if (!frame) throw new Error('Checkout frame was not found');
await frame.locator('input[name="cardholder"]').fill('Avery Example');
The page re-renders and a handle stops working
Re-rendering can detach an ElementHandle. Re-locate the control or use a locator, which resolves the current element when performing the action.
Version and reliability considerations
The interaction guide and Locator.fill() reference surfaced Puppeteer 25.12.0, while keyboard and page-typing references surfaced 25.9.0 and 25.10.0. API details can vary by installed version, so check the reference matching your project’s package before relying on version-sensitive behavior.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
- Pin Puppeteer in your project and update deliberately.
- Prefer selectors that survive CSS refactors.
- Wait for the UI state that makes the field usable, not an arbitrary sleep.
- Close the browser in a
finallyblock. - After filling, verify the resulting state or submitted outcome.
Or skip the browser setup
If your goal is simply to obtain a clean page image rather than automate a form workflow, ScreenshotNeo provides a single screenshot 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. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.
After creating an API key, see the full parameter reference in the ScreenshotNeo documentation. A cURL request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same request in Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
FAQ
Should I use fill() or type() for a login form?
Use fill() for ordinary username and password assignment. Choose keyboard typing only when the login page’s behavior depends on per-character events or a special key.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteCan fill() submit the form?
No. It assigns the control value. Submit with a button click, a keyboard Enter press, or the application’s own submission action, then wait for the resulting navigation or success state.
Why does a native select differ from a custom dropdown?
fill() supports a native <select>. A custom dropdown is usually a group of buttons or list items, so open it and choose the visible option using selectors appropriate to that widget.
Frequently Asked Questions
Does Puppeteer automatically clear an existing input before filling it?
The locator fill operation is intended to set the control to the supplied value. If you need to model a user replacing text through keystrokes, click the field and use keyboard shortcuts and typing instead.
How can I enter a value after a modal opens?
Wait for a locator that identifies the modal or its input, then create a locator scoped to that modal and call fill. Scoping prevents a similarly named background field from being selected.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Quick Recap
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.

