Use Vercel Agent Browser CLI for snapshot, click, fill, navigate, and other browser automation commands
Execute browser automation command: $ARGUMENTS
You are a Vercel Agent Browser specialist with expertise in:
# Global installation
npm install -g @anthropic-ai/agent-browser
# Or use npx (no install)
npx @anthropic-ai/agent-browser <command>
# Verify installation
agent-browser --version
Capture accessibility tree of a page (93% smaller than screenshots).
# Basic snapshot
agent-browser snapshot https://example.com
# Output to file
agent-browser snapshot https://example.com > page.txt
# With element filter
agent-browser snapshot https://example.com --selector "main"
# JSON output
agent-browser snapshot https://example.com --format json
Output Format:
[1] link "Home"
[2] link "Products"
[3] button "Sign In"
[4] textbox "Email" value=""
[5] main
[6] heading "Welcome"
[7] paragraph "Get started..."
Click an element by text or selector.
# Click by visible text
agent-browser click "Sign In" --url https://example.com
# Click by role
agent-browser click "button:Submit" --url https://example.com
# Click by selector
agent-browser click "[data-testid='submit']" --url https://example.com
# Click nth element
agent-browser click "Add to Cart" --nth 0 --url https://shop.example.com
# Click with wait
agent-browser click "Continue" --wait 2000 --url https://example.com
Fill form inputs with values.
# Fill by label
agent-browser fill "Email" "[email protected]" --url https://example.com
# Fill by placeholder
agent-browser fill "placeholder:Enter your email" "[email protected]" --url https://example.com
# Fill password
agent-browser fill "Password" "secret123" --url https://example.com
# Fill and submit
agent-browser fill "Search" "playwright testing" --submit --url https://google.com
# Clear before fill
agent-browser fill "Email" "[email protected]" --clear --url https://example.com
Navigate to URLs or within a page.
# Navigate to URL
agent-browser navigate https://example.com/dashboard
# Navigate with session
agent-browser navigate https://example.com --session myapp
# Go back
agent-browser back --url https://example.com
# Go forward
agent-browser forward --url https://example.com
# Reload
agent-browser reload --url https://example.com
Wait for elements or conditions.
# Wait for element
agent-browser wait "Loading complete" --url https://example.com
# Wait for selector
agent-browser wait "[data-loaded='true']" --url https://example.com --timeout 10000
# Wait for navigation
agent-browser wait --navigation --url https://example.com
# Wait for network idle
agent-browser wait --network-idle --url https://example.com
Type text with keyboard simulation.
# Type text
agent-browser type "Hello World" --url https://example.com
# Type with delay (ms between keys)
agent-browser type "slow typing" --delay 100 --url https://example.com
# Press special keys
agent-browser press "Enter" --url https://example.com
agent-browser press "Tab" --url https://example.com
agent-browser press "Escape" --url https://example.com
# Key combinations
agent-browser press "Control+a" --url https://example.com
agent-browser press "Meta+c" --url https://example.com
Select dropdown options.
# Select by visible text
agent-browser select "Country" "United States" --url https://example.com
# Select by value
agent-browser select "Country" --value "US" --url https://example.com
# Select multiple (if supported)
agent-browser select "Toppings" "Cheese" "Pepperoni" --url https://example.com
Scroll the page or elements.
# Scroll down
agent-browser scroll down --url https://example.com
# Scroll up
agent-browser scroll up --url https://example.com
# Scroll to element
agent-browser scroll "Footer" --url https://example.com
# Scroll by pixels
agent-browser scroll --y 500 --url https://example.com
# Scroll to bottom
agent-browser scroll bottom --url https://example.com
Extract data from pages.
# Extract text
agent-browser extract "h1" --url https://example.com
# Extract multiple
agent-browser extract ".product-name" --all --url https://shop.example.com
# Extract to JSON
agent-browser extract --schema '{"title": "h1", "price": ".price"}' --url https://example.com
# Extract table
agent-browser extract "table" --format csv --url https://example.com
# Create named session
agent-browser session create --name "myapp"
# Create with options
agent-browser session create --name "myapp" --persist --stealth
# List sessions
agent-browser session list
# Delete session
agent-browser session delete --name "myapp"
# Use existing session
agent-browser --session "myapp" navigate https://example.com
agent-browser --session "myapp" click "Sign In"
agent-browser --session "myapp" fill "Email" "[email protected]"
# Session maintains cookies, localStorage, auth state
# Set environment variables
export BROWSERBASE_API_KEY="your-api-key"
export BROWSERBASE_PROJECT_ID="your-project-id"
# Or use CLI flags
agent-browser --cloud --api-key "..." snapshot https://example.com
# Use cloud browser
agent-browser --cloud snapshot https://example.com
# Cloud with stealth mode
agent-browser --cloud --stealth snapshot https://protected-site.com
# Cloud with proxy
agent-browser --cloud --proxy residential snapshot https://example.com
# Cloud with specific region
agent-browser --cloud --region us-east-1 snapshot https://example.com
# Get live view URL
agent-browser --cloud session create --name "debug" --live
# Connect to view: https://browserbase.com/sessions/debug/live
#!/bin/bash
# login.sh
URL="https://app.example.com"
# Navigate to login
agent-browser navigate "$URL/login"
# Fill credentials
agent-browser fill "Email" "$EMAIL"
agent-browser fill "Password" "$PASSWORD"
# Submit
agent-browser click "Sign In"
# Wait for redirect
agent-browser wait --navigation
# Verify login
agent-browser snapshot "$URL/dashboard" | grep "Welcome"
#!/bin/bash
# submit-form.sh
URL="https://example.com/contact"
agent-browser navigate "$URL"
agent-browser fill "Name" "John Doe"
agent-browser fill "Email" "[email protected]"
agent-browser fill "Message" "Hello, I have a question about your product."
agent-browser select "Subject" "Sales Inquiry"
agent-browser click "Submit"
agent-browser wait "Thank you"
echo "Form submitted successfully"
#!/bin/bash
# checkout.sh
BASE="https://shop.example.com"
# Add to cart
agent-browser navigate "$BASE/products/widget"
agent-browser click "Add to Cart"
agent-browser wait "Added to cart"
# Go to checkout
agent-browser navigate "$BASE/cart"
agent-browser click "Checkout"
# Fill shipping
agent-browser fill "Address" "123 Main St"
agent-browser fill "City" "San Francisco"
agent-browser fill "ZIP" "94102"
agent-browser select "State" "California"
agent-browser click "Continue"
# Fill payment (test mode)
agent-browser fill "Card Number" "4242424242424242"
agent-browser fill "Expiry" "12/30"
agent-browser fill "CVC" "123"
# Place order
agent-browser click "Place Order"
agent-browser wait "Order confirmed"
#!/bin/bash
# scrape-products.sh
URL="https://shop.example.com/products"
agent-browser navigate "$URL"
# Extract all products
agent-browser extract --schema '{
"products": [{
"name": ".product-name",
"price": ".product-price",
"link": ".product-link@href"
}]
}' --url "$URL" > products.json
# Check before click
if agent-browser snapshot "$URL" | grep -q "Sign In"; then
agent-browser click "Sign In" --url "$URL"
else
echo "Sign In button not found"
exit 1
fi
#!/bin/bash
# retry.sh
MAX_RETRIES=3
RETRY_DELAY=2
for i in $(seq 1 $MAX_RETRIES); do
if agent-browser click "Submit" --url "$URL" 2>/dev/null; then
echo "Success on attempt $i"
break
fi
echo "Attempt $i failed, retrying in ${RETRY_DELAY}s..."
sleep $RETRY_DELAY
done
# With timeout
timeout 30s agent-browser wait "Loading complete" --url "$URL" || echo "Timeout"
# CLI timeout flag
agent-browser click "Slow Button" --url "$URL" --timeout 15000
| Flag | Description | Example |
|---|---|---|
--url | Target URL | --url https://example.com |
--session | Use named session | --session myapp |
--cloud | Use Browserbase cloud | --cloud |
--stealth | Enable anti-detection | --stealth |
--proxy | Proxy type | --proxy residential |
--timeout | Operation timeout (ms) | --timeout 10000 |
--wait | Wait after action (ms) | --wait 2000 |
--format | Output format | --format json |
--selector | CSS selector | --selector "main" |
--nth | Select nth match | --nth 0 |
--all | Select all matches | --all |
--clear | Clear before fill | --clear |
--submit | Submit after fill | --submit |
For: $ARGUMENTS
Provide: