Skip to main content
Type text character-by-character into an input field. Unlike fill, this triggers keystroke events for each character - use it for fields that react to individual key presses (search autocomplete, OTP inputs). Python only.
# Character-by-character input
await page.type("#search", value="query text")

# AI-powered type
await page.type(prompt="Type 'hello' into the search box")

# Selector with AI fallback
await page.type("#search", value="query text", prompt="Type into the search field")

# TOTP input
await page.type("#otp", totp_identifier="my-app", totp_url="otpauth://totp/...")
ParameterTypeRequiredDescription
selectorstrNoCSS or XPath selector for the input field.
valuestrNoText to type character-by-character.
aistrNoControls AI behavior. Default "fallback" tries the selector first, then AI.
promptstrNoNatural-language description of the target field.
totp_identifierstrNoIdentifier for a stored TOTP secret.
totp_urlstrNootpauth:// URI to generate a one-time password on the fly.
Returns str - the resolved selector used.