Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/browser-use/browser-use/llms.txt

Use this file to discover all available pages before exploring further.

Browser Use can automatically fill out and submit web forms, making it perfect for automating repetitive data entry tasks.

Basic Form Filling

This example demonstrates how to fill out a contact form with specific information:
import asyncio
from browser_use import Agent, ChatBrowserUse
from dotenv import load_dotenv

load_dotenv()

async def main():
    # Initialize the model
    llm = ChatBrowserUse(model='bu-2-0')
    
    # Define a form filling task
    task = """
    Go to https://httpbin.org/forms/post and fill out the contact form with:
    - Customer name: John Doe
    - Telephone: 555-123-4567
    - Email: john.doe@example.com
    - Size: Medium
    - Topping: cheese
    - Delivery time: now
    - Comments: This is a test form submission
    
    Then submit the form and tell me what response you get.
    """
    
    # Create and run the agent
    agent = Agent(task=task, llm=llm)
    await agent.run()

if __name__ == '__main__':
    asyncio.run(main())

How It Works

1

Navigate to Form

The agent navigates to the target URL containing the form
2

Identify Form Fields

Browser Use automatically identifies interactive form elements on the page
3

Fill Fields

The agent fills each field with the specified data in the correct order
4

Submit Form

Once all fields are filled, the agent submits the form and returns the result

Multi-Field Forms

For complex forms with multiple sections, you can provide detailed instructions:
task = """
Fill out the registration form with:

Personal Information:
- First Name: Jane
- Last Name: Smith
- Email: jane.smith@example.com
- Phone: (555) 123-4567

Address:
- Street: 123 Main St
- City: San Francisco
- State: CA
- ZIP: 94102

Preferences:
- Newsletter: Yes
- Contact method: Email

Then click the Submit button and confirm the registration.
"""

agent = Agent(task=task, llm=ChatBrowserUse())
await agent.run()

Handling Different Input Types

Browser Use can handle various form input types:

Text Inputs

task = "Fill the username field with 'john_doe' and password with 'SecurePass123'"
task = "Select 'United States' from the country dropdown and 'California' from the state dropdown"

Radio Buttons

task = "Select 'Male' for gender and 'Yes' for newsletter subscription"

Checkboxes

task = "Check the boxes for 'Terms of Service' and 'Privacy Policy'"

File Uploads

task = "Upload the file 'resume.pdf' to the file upload field"

Error Handling

Browser Use automatically handles common form issues:
agent = Agent(
    task="Fill out the form...",
    llm=ChatBrowserUse(),
    max_failures=3  # Retry up to 3 times if errors occur
)

Form Validation

The agent can verify that forms were filled correctly:
task = """
Fill out the contact form with my information:
- Name: John Doe
- Email: john@example.com

After filling, verify that:
1. All required fields are filled (look for red asterisks)
2. Email format is valid (no error messages)
3. Submit the form only if validation passes
"""

Tips for Form Filling

Important: Be specific about field names and values to ensure accurate form filling.
  • Use exact field labels as they appear on the page
  • For dropdowns, specify the exact option text
  • Allow time for page loads and dynamic content
  • Test with the form’s actual validation rules