You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Default screenshot mode**: Light mode (run `agent-browser set media light` before capturing) — required when creating docs for `@wiki`
81
+
82
+
## Dev Server Check (REQUIRED)
83
+
84
+
Before running any browser automation, **always** check if the target port needs its own dev server spun up to avoid accidentally using a dev server from a different worktree:
85
+
86
+
```bash
87
+
# 1. Check what's already running on the target port
88
+
lsof -i :5173 -t 2>/dev/null &&echo"Port in use"||echo"Port free"
89
+
90
+
# 2. If in use, verify the process CWD matches this worktree
91
+
ls -l /proc/$(lsof -i :5173 -t 2>/dev/null | head -1)/cwd 2>/dev/null
92
+
```
93
+
94
+
If the running server's working directory does NOT match the current worktree, start a new dev server on an available port and use that instead.
95
+
36
96
## Agent Workflow
37
97
38
-
1.**Navigate + snapshot**: `agent-browser open <url> && agent-browser snapshot --json`
39
-
2.**Parse refs** from JSON output to identify interactive elements
40
-
3.**Act** using refs: `agent-browser click @e2`, `agent-browser fill @e3 "hello"`
41
-
4.**Re-snapshot** after each action to observe new state
42
-
5.**Screenshot** when visual verification is needed
98
+
1.**Check dev server** (see above) — start one if needed
99
+
2.**Navigate + snapshot**: `agent-browser open <url> && agent-browser snapshot --json`
100
+
3.**Parse refs** from JSON output to identify interactive elements
101
+
4.**Act** using refs: `agent-browser click @e2`, `agent-browser fill @e3 "hello"`
102
+
5.**Re-snapshot** after each action to observe new state
103
+
6.**Screenshot** when visual verification is needed (light mode for wiki docs)
43
104
44
105
## JSON Output
45
106
@@ -52,6 +113,16 @@ Add `--json` to any command for structured output:
52
113
53
114
Use `--session <name>` for isolated sessions or `--profile <path>` for persistent cookies/storage.
54
115
116
+
## Troubleshooting
117
+
118
+
If you run into issues with any command, run `agent-browser --help` to check available commands and flags. Common fixes:
119
+
120
+
-**Element not found**: Re-run `agent-browser snapshot` to get fresh refs — refs change after page mutations
121
+
-**Timeout**: Use `agent-browser wait <sel>` before interacting with dynamically loaded elements
122
+
-**Can't see what's happening**: Add `--headed` to see the browser, or `--debug` for verbose output
123
+
-**Stale session**: Run `agent-browser close` and start fresh
124
+
-**Check specific command help**: Most commands support `--json` for structured output to debug responses
125
+
55
126
## Full Documentation
56
127
57
128
See https://github.com/vercel-labs/agent-browser for complete docs, cloud provider setup, and WebSocket streaming.
0 commit comments