Skip to main content
Use fill_form to fill a form in one call. For more control, extract_form_fields lists the fields, dynamic_field_map maps your data onto them, and fill_from_mapping fills them.

page.fill_form

Scan page for form fields, map data to fields via LLM, and fill them. This is the primary SDK interface for form filling. It composes:
  1. extract_form_fields() — scan all fields from the DOM (free)
  2. dynamic_field_map() — one LLM call to map data to fields
  3. validate_mapping() — one LLM call to check user conditions
  4. fill_from_mapping() — fill via CSS selectors with AI fallback
Python only: the TypeScript SDK has no equivalent.
Parameters
dict[str, Any]
required
Dict of data keys/values to fill into the form.
str
User instructions for how to fill the form.Default: 'Fill out the form'
Returns None Example

page.fill_multipage_form

Fill a multi-page form by looping: fill current page → click next → repeat. Returns the number of pages filled. Stops when:
  • No fillable form fields are found on the current page (e.g., Review page)
  • The next button is not found (last page)
  • max_pages is reached
  • Wall-clock timeout is exceeded
Python only: the TypeScript SDK has no equivalent.
Parameters
dict[str, Any]
required
Dict of data keys/values to fill into the form.
str
User instructions for how to fill the form.Default: 'Fill out the form'
str
CSS selector(s) for the next/continue button.Default: 'button:has-text("Save and Continue"), button:has-text("Next"), button:has-text("Continue")'
int
Safety limit on number of pages to fill.Default: 10
float
Wall-clock timeout for the entire multi-page fill (default 5 min).Default: 300
str | None
Default: None
Returns int Example

page.extract_form_fields

Scan the page for visible form fields using DOM inspection (no LLM). The base scanner handles standard HTML form elements (input, select, textarea) and ARIA role-based groups. Platform-specific passes (e.g., custom listbox buttons, multiselect widgets) are injected at runtime via AgentFunction.get_form_field_extraction_js(). Returns a list of field descriptors.
Python only: the TypeScript SDK has no equivalent.
Returns list[dict[str, Any]] Example

page.dynamic_field_map

Map data to form fields via a single cheap text-only LLM call. One LLM call sees ALL fields + ALL data and produces a complete mapping — no deterministic matching, no caching, no accumulated state.
Python only: the TypeScript SDK has no equivalent.
Parameters
list[dict[str, Any]]
required
Output of extract_form_fields.
dict[str, Any]
required
Flat dict of data keys/values to map to form fields.
str | None
Default: None
Returns dict[int, str | list | bool | None] — Mapping of 0-based field index -> value to fill (or None to skip). Example

page.fill_from_mapping

Fill form fields using a pre-computed mapping from dynamic_field_map. Iterates over the mapping and fills each field using the appropriate browser method based on field type. No LLM calls — pure execution.
Python only: the TypeScript SDK has no equivalent.
Parameters
list[dict[str, Any]]
required
Output of extract_form_fields.
dict[int, str | list | bool | None]
required
Output of dynamic_field_map (index -> value).
dict[str, Any] | None
Original data dict for post-fill file upload matching.Default: None
Returns None Example

page.validate_mapping

Validate the field mapping against the user’s prompt/instructions. Makes one LLM call that sees the prompt (user instructions), the form fields, and what was mapped to each field. Returns True if the run should complete, False if it should terminate. This catches user directives like “terminate if you can’t answer the security clearance question” or “never fabricate answers — fail if data is missing for required fields.”
Python only: the TypeScript SDK has no equivalent.
Parameters
list[dict[str, Any]]
required
Output of extract_form_fields.
dict[int, str | list | bool | None]
required
Output of dynamic_field_map.
str | None
required
The user’s instructions/prompt for this automation.
Returns bool — True to complete, False to terminate. Example

page.fill_autocomplete

Fill an autocomplete input by typing a value and clicking the matching dropdown option. Handles widgets like Google Places, autocomplete location fields, and other autocomplete inputs where typing triggers a dropdown and the user must select an option for the value to persist. The flow:
  1. Clear the field and type the value character-by-character (triggers autocomplete)
  2. Wait for dropdown options to appear
  3. Find the best-matching option by text similarity
  4. Click it so the value is committed
If no dropdown options appear, falls back to the same behavior as page.fill().
Python only: the TypeScript SDK has no equivalent.
Parameters
str | None
CSS selector for the input field.Default: None
str | None
The text to type (e.g. “San Francisco, CA”).Default: None
str | None
Natural language description for AI fallback.Default: None
str | None
AI behavior mode (same as fill). Defaults to “fallback”.Default: 'fallback'
str | None
CSS selector for the dropdown options. If not provided, tries common patterns: [role="option"], .pac-item, li[role="option"], [data-option-id].Default: None
float
How long to wait for dropdown options to appear after typing. Defaults to 1.5 seconds.Default: 1.5
Returns str — The value that was selected from the dropdown, or the typed value if no dropdown appeared. Example