$npx -y skills add wshaddix/dotnet-skills --skill agent-browserBrowser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a websit
| 1 | # Browser Automation with agent-browser |
| 2 | |
| 3 | ## Core Workflow |
| 4 | |
| 5 | Every browser automation follows this pattern: |
| 6 | |
| 7 | 1. **Navigate**: `agent-browser open <url>` |
| 8 | 2. **Snapshot**: `agent-browser snapshot -i` (get element refs like `@e1`, `@e2`) |
| 9 | 3. **Interact**: Use refs to click, fill, select |
| 10 | 4. **Re-snapshot**: After navigation or DOM changes, get fresh refs |
| 11 | |
| 12 | ```bash |
| 13 | agent-browser open https://example.com/form |
| 14 | agent-browser snapshot -i |
| 15 | # Output: @e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit" |
| 16 | |
| 17 | agent-browser fill @e1 "user@example.com" |
| 18 | agent-browser fill @e2 "password123" |
| 19 | agent-browser click @e3 |
| 20 | agent-browser wait --load networkidle |
| 21 | agent-browser snapshot -i # Check result |
| 22 | ``` |
| 23 | |
| 24 | ## Essential Commands |
| 25 | |
| 26 | ```bash |
| 27 | # Navigation |
| 28 | agent-browser open <url> # Navigate (aliases: goto, navigate) |
| 29 | agent-browser close # Close browser |
| 30 | |
| 31 | # Snapshot |
| 32 | agent-browser snapshot -i # Interactive elements with refs (recommended) |
| 33 | agent-browser snapshot -i -C # Include cursor-interactive elements (divs with onclick, cursor:pointer) |
| 34 | agent-browser snapshot -s "#selector" # Scope to CSS selector |
| 35 | |
| 36 | # Interaction (use @refs from snapshot) |
| 37 | agent-browser click @e1 # Click element |
| 38 | agent-browser fill @e2 "text" # Clear and type text |
| 39 | agent-browser type @e2 "text" # Type without clearing |
| 40 | agent-browser select @e1 "option" # Select dropdown option |
| 41 | agent-browser check @e1 # Check checkbox |
| 42 | agent-browser press Enter # Press key |
| 43 | agent-browser scroll down 500 # Scroll page |
| 44 | |
| 45 | # Get information |
| 46 | agent-browser get text @e1 # Get element text |
| 47 | agent-browser get url # Get current URL |
| 48 | agent-browser get title # Get page title |
| 49 | |
| 50 | # Wait |
| 51 | agent-browser wait @e1 # Wait for element |
| 52 | agent-browser wait --load networkidle # Wait for network idle |
| 53 | agent-browser wait --url "**/page" # Wait for URL pattern |
| 54 | agent-browser wait 2000 # Wait milliseconds |
| 55 | |
| 56 | # Capture |
| 57 | agent-browser screenshot # Screenshot to temp dir |
| 58 | agent-browser screenshot --full # Full page screenshot |
| 59 | agent-browser pdf output.pdf # Save as PDF |
| 60 | ``` |
| 61 | |
| 62 | ## Common Patterns |
| 63 | |
| 64 | ### Form Submission |
| 65 | |
| 66 | ```bash |
| 67 | agent-browser open https://example.com/signup |
| 68 | agent-browser snapshot -i |
| 69 | agent-browser fill @e1 "Jane Doe" |
| 70 | agent-browser fill @e2 "jane@example.com" |
| 71 | agent-browser select @e3 "California" |
| 72 | agent-browser check @e4 |
| 73 | agent-browser click @e5 |
| 74 | agent-browser wait --load networkidle |
| 75 | ``` |
| 76 | |
| 77 | ### Authentication with State Persistence |
| 78 | |
| 79 | ```bash |
| 80 | # Login once and save state |
| 81 | agent-browser open https://app.example.com/login |
| 82 | agent-browser snapshot -i |
| 83 | agent-browser fill @e1 "$USERNAME" |
| 84 | agent-browser fill @e2 "$PASSWORD" |
| 85 | agent-browser click @e3 |
| 86 | agent-browser wait --url "**/dashboard" |
| 87 | agent-browser state save auth.json |
| 88 | |
| 89 | # Reuse in future sessions |
| 90 | agent-browser state load auth.json |
| 91 | agent-browser open https://app.example.com/dashboard |
| 92 | ``` |
| 93 | |
| 94 | ### Session Persistence |
| 95 | |
| 96 | ```bash |
| 97 | # Auto-save/restore cookies and localStorage across browser restarts |
| 98 | agent-browser --session-name myapp open https://app.example.com/login |
| 99 | # ... login flow ... |
| 100 | agent-browser close # State auto-saved to ~/.agent-browser/sessions/ |
| 101 | |
| 102 | # Next time, state is auto-loaded |
| 103 | agent-browser --session-name myapp open https://app.example.com/dashboard |
| 104 | |
| 105 | # Encrypt state at rest |
| 106 | export AGENT_BROWSER_ENCRYPTION_KEY=$(openssl rand -hex 32) |
| 107 | agent-browser --session-name secure open https://app.example.com |
| 108 | |
| 109 | # Manage saved states |
| 110 | agent-browser state list |
| 111 | agent-browser state show myapp-default.json |
| 112 | agent-browser state clear myapp |
| 113 | agent-browser state clean --older-than 7 |
| 114 | ``` |
| 115 | |
| 116 | ### Data Extraction |
| 117 | |
| 118 | ```bash |
| 119 | agent-browser open https://example.com/products |
| 120 | agent-browser snapshot -i |
| 121 | agent-browser get text @e5 # Get specific element text |
| 122 | agent-browser get text body > page.txt # Get all page text |
| 123 | |
| 124 | # JSON output for parsing |
| 125 | agent-browser snapshot -i --json |
| 126 | agent-browser get text @e1 --json |
| 127 | ``` |
| 128 | |
| 129 | ### Parallel Sessions |
| 130 | |
| 131 | ```bash |
| 132 | agent-browser --session site1 open https://site-a.com |
| 133 | agent-browser --session site2 open https://site-b.com |
| 134 | |
| 135 | agent-browser --session site1 snapshot -i |
| 136 | agent-browser --session site2 snapshot -i |
| 137 | |
| 138 | agent-browser session list |
| 139 | ``` |
| 140 | |
| 141 | ### Connect to Existing Chrome |
| 142 | |
| 143 | ```bash |
| 144 | # Auto-discover running Chrome with remote debugging enabled |
| 145 | agent-browser --auto-connect open https://example.com |
| 146 | agent-browser --auto |