Frontend Testing with Agent-Browser
Test the web interface using agent-browser for interactive browser automation and validation.
Prerequisites
Ensure the local server is running:
make run-local # Starts server on localhost:8080
Basic Usage
1. Open the browser
agent-browser open "http://127.0.0.1:8080$ARGUMENTS"
If no arguments provided, opens the root page.
2. Take a snapshot
Get the accessibility tree with element references:
agent-browser snapshot
This shows all interactive elements with unique IDs (e.g., @e5, @e12)
3. Interact with elements
# Click on an element
agent-browser click @e5
# Fill a form field
agent-browser fill @e12 "test@example.com"
# Type text
agent-browser type @e8 "password123"
4. Capture screenshots
agent-browser screenshot /tmp/page.png
5. Close browser
agent-browser close
Common Testing Scenarios
Login Flow Validation
- Open login page
- Snapshot to find form elements
- Fill username and password fields
- Click submit button
- Verify redirect and session
HTMX Dynamic Updates
- Load page with HTMX components
- Take snapshot before interaction
- Trigger HTMX action (click, form submit)
- Take snapshot after to verify DOM updates
- Confirm expected changes occurred
Form Submission
- Navigate to form page
- Identify form fields via snapshot
- Fill all required fields
- Submit form
- Verify success message or redirect
Session Management
- Test login/logout flow
- Verify session persistence
- Check unauthorized access handling
Full Example Workflow
# 1. Start local server (if not running)
make run-local
# 2. In another terminal, test login
agent-browser open "http://127.0.0.1:8080/login"
agent-browser snapshot # Find username/password field IDs
# 3. Fill login form (replace @e5, @e6 with actual IDs)
agent-browser fill @e5 "admin@example.com"
agent-browser fill @e6 "password123"
agent-browser click @e7 # Submit button
# 4. Verify redirect to dashboard
agent-browser snapshot # Should show dashboard elements
# 5. Take screenshot for documentation
agent-browser screenshot /tmp/dashboard.png
# 6. Cleanup
agent-browser close
Tips
- Always take a snapshot first to find element IDs
- Use
--noproxy '*'with curl for health checks - Element IDs are temporary - get fresh snapshot after page changes
- Screenshots help document UI state for debugging
Documentation
Full command reference: https://github.com/vercel-labs/agent-browser
Converted and distributed by TomeVault — claim your Tome and manage your conversions.