@dyyz1993/agent-browser 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/utils/parseCli.d.ts +1 -0
- package/dist/__tests__/utils/parseCli.d.ts.map +1 -1
- package/dist/__tests__/utils/parseCli.js +18 -10
- package/dist/__tests__/utils/parseCli.js.map +1 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +63 -3
- package/dist/actions.js.map +1 -1
- package/dist/browser.d.ts +46 -2
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +343 -13
- package/dist/browser.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +8 -3
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/connection.d.ts.map +1 -1
- package/dist/cli/connection.js +39 -1
- package/dist/cli/connection.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +27 -20
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/output.d.ts.map +1 -1
- package/dist/cli/output.js +5 -0
- package/dist/cli/output.js.map +1 -1
- package/dist/cli.js +20 -0
- package/dist/cli.js.map +1 -1
- package/dist/daemon.d.ts.map +1 -1
- package/dist/daemon.js +147 -1
- package/dist/daemon.js.map +1 -1
- package/dist/message-bridge.d.ts.map +1 -1
- package/dist/message-bridge.js +22 -4
- package/dist/message-bridge.js.map +1 -1
- package/dist/openapi.d.ts +22 -0
- package/dist/openapi.d.ts.map +1 -0
- package/dist/openapi.js +382 -0
- package/dist/openapi.js.map +1 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +18 -0
- package/dist/protocol.js.map +1 -1
- package/dist/recorder/inject.js +61 -134
- package/dist/stream-server-standalone.d.ts +10 -0
- package/dist/stream-server-standalone.d.ts.map +1 -1
- package/dist/stream-server-standalone.js +594 -74
- package/dist/stream-server-standalone.js.map +1 -1
- package/dist/stream-server.d.ts +67 -2
- package/dist/stream-server.d.ts.map +1 -1
- package/dist/stream-server.js +371 -51
- package/dist/stream-server.js.map +1 -1
- package/dist/swagger-ui.d.ts +6 -0
- package/dist/swagger-ui.d.ts.map +1 -0
- package/dist/swagger-ui.js +51 -0
- package/dist/swagger-ui.js.map +1 -0
- package/dist/test-live.d.ts +2 -0
- package/dist/test-live.d.ts.map +1 -0
- package/dist/test-live.js +333 -0
- package/dist/test-live.js.map +1 -0
- package/dist/types.d.ts +7 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/viewer-html.d.ts.map +1 -1
- package/dist/viewer-html.js +270 -58
- package/dist/viewer-html.js.map +1 -1
- package/dist/viewer-script.d.ts +20 -2
- package/dist/viewer-script.d.ts.map +1 -1
- package/dist/viewer-script.js +858 -102
- package/dist/viewer-script.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +6 -32
- package/scripts/test-cli-help.sh +51 -0
- package/scripts/verify-form.sh +67 -0
- package/scripts/verify-login.sh +65 -0
- package/scripts/verify-recording.sh +80 -0
- package/scripts/verify-upload.sh +41 -0
- package/skills/agent-browser/SKILL.md +88 -1
- package/skills/agent-browser/references/commands.md +3 -0
- package/skills/agent-browser/references/network-monitoring.md +232 -0
- package/skills/agent-browser/references/profiling.md +120 -0
- package/skills/agent-browser/references/recorder.md +319 -0
- package/skills/agent-browser/templates/network-intercept-crawl.sh +255 -0
- package/dist/__tests__/test-iframe.d.ts +0 -2
- package/dist/__tests__/test-iframe.d.ts.map +0 -1
- package/dist/__tests__/test-iframe.js +0 -52
- package/dist/__tests__/test-iframe.js.map +0 -1
- package/dist/cli-new.d.ts +0 -3
- package/dist/cli-new.d.ts.map +0 -1
- package/dist/cli-new.js +0 -308
- package/dist/cli-new.js.map +0 -1
- package/dist/cli-old.d.ts +0 -3
- package/dist/cli-old.d.ts.map +0 -1
- package/dist/cli-old.js +0 -1101
- package/dist/cli-old.js.map +0 -1
- package/dist/recorder/binding.d.ts +0 -24
- package/dist/recorder/binding.d.ts.map +0 -1
- package/dist/recorder/binding.js +0 -215
- package/dist/recorder/binding.js.map +0 -1
- package/dist/recorder/index.d.ts +0 -4
- package/dist/recorder/index.d.ts.map +0 -1
- package/dist/recorder/index.js +0 -4
- package/dist/recorder/index.js.map +0 -1
- package/dist/recorder/recorder.d.ts +0 -19
- package/dist/recorder/recorder.d.ts.map +0 -1
- package/dist/recorder/recorder.js +0 -101
- package/dist/recorder/recorder.js.map +0 -1
- package/dist/recorder/store.d.ts +0 -22
- package/dist/recorder/store.d.ts.map +0 -1
- package/dist/recorder/store.js +0 -150
- package/dist/recorder/store.js.map +0 -1
- package/dist/recorder/types.d.ts +0 -73
- package/dist/recorder/types.d.ts.map +0 -1
- package/dist/recorder/types.js +0 -5
- package/dist/recorder/types.js.map +0 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Network Request Monitoring
|
|
2
|
+
|
|
3
|
+
The `network` command provides powerful network interception and monitoring capabilities for testing APIs, blocking unwanted requests, mocking responses, and debugging network behavior.
|
|
4
|
+
|
|
5
|
+
## Basic Network Monitoring
|
|
6
|
+
|
|
7
|
+
### View All Network Requests
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Start monitoring network requests
|
|
11
|
+
agent-browser network requests
|
|
12
|
+
|
|
13
|
+
# Clear request history
|
|
14
|
+
agent-browser network requests --clear
|
|
15
|
+
|
|
16
|
+
# Filter requests by URL pattern
|
|
17
|
+
agent-browser network requests --filter "**/api/**"
|
|
18
|
+
agent-browser network requests --filter "**/json"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Example: Monitor API Calls
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Open a page
|
|
25
|
+
agent-browser open https://httpbin.org/delay/1
|
|
26
|
+
|
|
27
|
+
# View all network requests made
|
|
28
|
+
agent-browser network requests
|
|
29
|
+
|
|
30
|
+
# Filter to see only JSON responses
|
|
31
|
+
agent-browser network requests --filter "**/json"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Request Interception (Routing)
|
|
35
|
+
|
|
36
|
+
### Mock API Responses
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Set up a mock response for a URL pattern
|
|
40
|
+
agent-browser network route "**/api/users" --body '{"users": [{"id": 1, "name": "Mock User"}]}'
|
|
41
|
+
|
|
42
|
+
# Now any request to /api/users will return the mock data
|
|
43
|
+
agent-browser open https://example.com
|
|
44
|
+
|
|
45
|
+
# Remove the route
|
|
46
|
+
agent-browser network unroute "**/api/users"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Block Unwanted Requests
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Block ads or tracking scripts
|
|
53
|
+
agent-browser network route "**/ads/**" --abort
|
|
54
|
+
agent-browser network route "**/tracking/**" --abort
|
|
55
|
+
|
|
56
|
+
# Block specific domains
|
|
57
|
+
agent-browser network route "**/analytics.google.com/**" --abort
|
|
58
|
+
|
|
59
|
+
# Remove block
|
|
60
|
+
agent-browser network unroute "**/ads/**"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Recording Network Activity
|
|
64
|
+
|
|
65
|
+
### During Recorder Session
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Start recording session
|
|
69
|
+
agent-browser recorder start --session network-test
|
|
70
|
+
|
|
71
|
+
# Navigate and perform actions
|
|
72
|
+
agent-browser open https://httpbin.org/get
|
|
73
|
+
agent-browser open https://httpbin.org/json
|
|
74
|
+
|
|
75
|
+
# View network requests during recording
|
|
76
|
+
agent-browser network requests
|
|
77
|
+
agent-browser network requests --filter "**/json"
|
|
78
|
+
|
|
79
|
+
# Stop recording
|
|
80
|
+
agent-browser recorder stop --output network-test.yaml
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Advanced Patterns
|
|
84
|
+
|
|
85
|
+
### Debug API Issues
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# 1. Clear previous requests
|
|
89
|
+
agent-browser network requests --clear
|
|
90
|
+
|
|
91
|
+
# 2. Navigate to trigger API calls
|
|
92
|
+
agent-browser open https://example.com/dashboard
|
|
93
|
+
|
|
94
|
+
# 3. Check what requests were made
|
|
95
|
+
agent-browser network requests
|
|
96
|
+
|
|
97
|
+
# 4. Filter for specific endpoints
|
|
98
|
+
agent-browser network requests --filter "**/api/v1/**"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Test Error Handling
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
# Mock error responses
|
|
105
|
+
agent-browser network route "**/api/critical" --body '{"error": "Service unavailable"}'
|
|
106
|
+
|
|
107
|
+
# Or block the request entirely
|
|
108
|
+
agent-browser network route "**/api/critical" --abort
|
|
109
|
+
|
|
110
|
+
# Test how your app handles the error
|
|
111
|
+
agent-browser open https://example.com
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Performance Testing
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# Monitor requests while testing
|
|
118
|
+
agent-browser network requests --clear
|
|
119
|
+
|
|
120
|
+
# Perform actions
|
|
121
|
+
agent-browser click @e1
|
|
122
|
+
agent-browser wait --load networkidle
|
|
123
|
+
|
|
124
|
+
# Check how many requests were made
|
|
125
|
+
agent-browser network requests
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## URL Pattern Matching
|
|
129
|
+
|
|
130
|
+
The routing uses glob patterns:
|
|
131
|
+
|
|
132
|
+
- `**/api/**` - Match any path containing /api/
|
|
133
|
+
- `**/api/users` - Match specific endpoint
|
|
134
|
+
- `**/*.json` - Match all JSON files
|
|
135
|
+
- `https://example.com/**` - Match specific domain
|
|
136
|
+
- `**/ads/**` - Match any ad URLs
|
|
137
|
+
|
|
138
|
+
## Integration with Recorder
|
|
139
|
+
|
|
140
|
+
Network monitoring works seamlessly with the recorder:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Start recording with network monitoring
|
|
144
|
+
agent-browser recorder start --session my-test
|
|
145
|
+
|
|
146
|
+
# Your workflow
|
|
147
|
+
agent-browser open https://example.com
|
|
148
|
+
agent-browser snapshot -i
|
|
149
|
+
agent-browser click @e1
|
|
150
|
+
|
|
151
|
+
# Check network requests
|
|
152
|
+
agent-browser network requests
|
|
153
|
+
|
|
154
|
+
# Stop and save
|
|
155
|
+
agent-browser recorder stop --output test-with-network.yaml
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Best Practices
|
|
159
|
+
|
|
160
|
+
1. **Clear before testing**: Use `--clear` to start fresh
|
|
161
|
+
```bash
|
|
162
|
+
agent-browser network requests --clear
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
2. **Filter effectively**: Use specific patterns to reduce noise
|
|
166
|
+
```bash
|
|
167
|
+
agent-browser network requests --filter "**/api/v2/**"
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
3. **Clean up routes**: Always remove test routes
|
|
171
|
+
```bash
|
|
172
|
+
agent-browser network unroute "**/test/**"
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
4. **Combine with wait**: Use network idle for comprehensive testing
|
|
176
|
+
```bash
|
|
177
|
+
agent-browser click @e1
|
|
178
|
+
agent-browser wait --load networkidle
|
|
179
|
+
agent-browser network requests
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Use Cases
|
|
183
|
+
|
|
184
|
+
- **API Testing**: Mock responses and test error handling
|
|
185
|
+
- **Performance**: Monitor request count and patterns
|
|
186
|
+
- **Debugging**: See what requests your app makes
|
|
187
|
+
- **Ad Blocking**: Block unwanted requests during testing
|
|
188
|
+
- **Offline Testing**: Block external dependencies
|
|
189
|
+
- **Security**: Audit what data is being sent
|
|
190
|
+
|
|
191
|
+
## Example Test Script
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
#!/bin/bash
|
|
195
|
+
|
|
196
|
+
# Test network monitoring with httpbin.org
|
|
197
|
+
|
|
198
|
+
# Start browser
|
|
199
|
+
agent-browser open https://httpbin.org
|
|
200
|
+
|
|
201
|
+
# Clear previous requests
|
|
202
|
+
agent-browser network requests --clear
|
|
203
|
+
|
|
204
|
+
# Make some requests
|
|
205
|
+
agent-browser open https://httpbin.org/get
|
|
206
|
+
agent-browser open https://httpbin.org/json
|
|
207
|
+
agent-browser open https://httpbin.org/html
|
|
208
|
+
|
|
209
|
+
# Check all requests
|
|
210
|
+
agent-browser network requests
|
|
211
|
+
|
|
212
|
+
# Filter JSON requests
|
|
213
|
+
agent-browser network requests --filter "**/json"
|
|
214
|
+
|
|
215
|
+
# Test mocking
|
|
216
|
+
agent-browser network route "**/test" --body '{"mocked": true}'
|
|
217
|
+
agent-browser open https://httpbin.org/test
|
|
218
|
+
agent-browser network unroute "**/test"
|
|
219
|
+
|
|
220
|
+
# Test blocking
|
|
221
|
+
agent-browser network route "**/blocked" --abort
|
|
222
|
+
|
|
223
|
+
# Clean up
|
|
224
|
+
agent-browser close
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Limitations
|
|
228
|
+
|
|
229
|
+
- Routes are session-specific and reset on browser close
|
|
230
|
+
- Request history is stored in memory and cleared on browser close
|
|
231
|
+
- Mock responses only work for simple JSON bodies
|
|
232
|
+
- For complex mocking, consider using a dedicated API mocking service
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Profiling
|
|
2
|
+
|
|
3
|
+
Capture Chrome DevTools performance profiles during browser automation for performance analysis.
|
|
4
|
+
|
|
5
|
+
**Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Basic Profiling](#basic-profiling)
|
|
10
|
+
- [Profiler Commands](#profiler-commands)
|
|
11
|
+
- [Categories](#categories)
|
|
12
|
+
- [Use Cases](#use-cases)
|
|
13
|
+
- [Output Format](#output-format)
|
|
14
|
+
- [Viewing Profiles](#viewing-profiles)
|
|
15
|
+
- [Limitations](#limitations)
|
|
16
|
+
|
|
17
|
+
## Basic Profiling
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Start profiling
|
|
21
|
+
agent-browser profiler start
|
|
22
|
+
|
|
23
|
+
# Perform actions
|
|
24
|
+
agent-browser navigate https://example.com
|
|
25
|
+
agent-browser click "#button"
|
|
26
|
+
agent-browser wait 1000
|
|
27
|
+
|
|
28
|
+
# Stop and save
|
|
29
|
+
agent-browser profiler stop ./trace.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Profiler Commands
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Start profiling with default categories
|
|
36
|
+
agent-browser profiler start
|
|
37
|
+
|
|
38
|
+
# Start with custom trace categories
|
|
39
|
+
agent-browser profiler start --categories "devtools.timeline,v8.execute,blink.user_timing"
|
|
40
|
+
|
|
41
|
+
# Stop profiling and save to file
|
|
42
|
+
agent-browser profiler stop ./trace.json
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Categories
|
|
46
|
+
|
|
47
|
+
The `--categories` flag accepts a comma-separated list of Chrome trace categories. Default categories include:
|
|
48
|
+
|
|
49
|
+
- `devtools.timeline` -- standard DevTools performance traces
|
|
50
|
+
- `v8.execute` -- time spent running JavaScript
|
|
51
|
+
- `blink` -- renderer events
|
|
52
|
+
- `blink.user_timing` -- `performance.mark()` / `performance.measure()` calls
|
|
53
|
+
- `latencyInfo` -- input-to-latency tracking
|
|
54
|
+
- `renderer.scheduler` -- task scheduling and execution
|
|
55
|
+
- `toplevel` -- broad-spectrum basic events
|
|
56
|
+
|
|
57
|
+
Several `disabled-by-default-*` categories are also included for detailed timeline, call stack, and V8 CPU profiling data.
|
|
58
|
+
|
|
59
|
+
## Use Cases
|
|
60
|
+
|
|
61
|
+
### Diagnosing Slow Page Loads
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
agent-browser profiler start
|
|
65
|
+
agent-browser navigate https://app.example.com
|
|
66
|
+
agent-browser wait --load networkidle
|
|
67
|
+
agent-browser profiler stop ./page-load-profile.json
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Profiling User Interactions
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
agent-browser navigate https://app.example.com
|
|
74
|
+
agent-browser profiler start
|
|
75
|
+
agent-browser click "#submit"
|
|
76
|
+
agent-browser wait 2000
|
|
77
|
+
agent-browser profiler stop ./interaction-profile.json
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### CI Performance Regression Checks
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
#!/bin/bash
|
|
84
|
+
agent-browser profiler start
|
|
85
|
+
agent-browser navigate https://app.example.com
|
|
86
|
+
agent-browser wait --load networkidle
|
|
87
|
+
agent-browser profiler stop "./profiles/build-${BUILD_ID}.json"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Output Format
|
|
91
|
+
|
|
92
|
+
The output is a JSON file in Chrome Trace Event format:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"traceEvents": [
|
|
97
|
+
{ "cat": "devtools.timeline", "name": "RunTask", "ph": "X", "ts": 12345, "dur": 100, ... },
|
|
98
|
+
...
|
|
99
|
+
],
|
|
100
|
+
"metadata": {
|
|
101
|
+
"clock-domain": "LINUX_CLOCK_MONOTONIC"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The `metadata.clock-domain` field is set based on the host platform (Linux or macOS). On Windows it is omitted.
|
|
107
|
+
|
|
108
|
+
## Viewing Profiles
|
|
109
|
+
|
|
110
|
+
Load the output JSON file in any of these tools:
|
|
111
|
+
|
|
112
|
+
- **Chrome DevTools**: Performance panel > Load profile (Ctrl+Shift+I > Performance)
|
|
113
|
+
- **Perfetto UI**: https://ui.perfetto.dev/ -- drag and drop the JSON file
|
|
114
|
+
- **Trace Viewer**: `chrome://tracing` in any Chromium browser
|
|
115
|
+
|
|
116
|
+
## Limitations
|
|
117
|
+
|
|
118
|
+
- Only works with Chromium-based browsers (Chrome, Edge). Not supported on Firefox or WebKit.
|
|
119
|
+
- Trace data accumulates in memory while profiling is active (capped at 5 million events). Stop profiling promptly after the area of interest.
|
|
120
|
+
- Data collection on stop has a 30-second timeout. If the browser is unresponsive, the stop command may fail.
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Recorder (Action Recording & Replay)
|
|
2
|
+
|
|
3
|
+
Record user interactions as structured steps that can be replayed or exported for LLM processing.
|
|
4
|
+
|
|
5
|
+
**Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Basic Recording](#basic-recording)
|
|
10
|
+
- [Recording Workflow](#recording-workflow)
|
|
11
|
+
- [Supported Actions](#supported-actions)
|
|
12
|
+
- [YAML Output Format](#yaml-output-format)
|
|
13
|
+
- [Replay Feature](#replay-feature)
|
|
14
|
+
- [Use Cases](#use-cases)
|
|
15
|
+
- [Best Practices](#best-practices)
|
|
16
|
+
|
|
17
|
+
## Basic Recording
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Start recording session
|
|
21
|
+
agent-browser recorder start
|
|
22
|
+
|
|
23
|
+
# Perform actions
|
|
24
|
+
agent-browser open https://example.com
|
|
25
|
+
agent-browser snapshot -i
|
|
26
|
+
agent-browser click @e1
|
|
27
|
+
agent-browser fill @e2 "test input"
|
|
28
|
+
agent-browser select @e3 "option"
|
|
29
|
+
|
|
30
|
+
# Stop recording and save to file
|
|
31
|
+
agent-browser recorder stop --output session.yaml
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Recording Workflow
|
|
35
|
+
|
|
36
|
+
The recorder captures all browser interactions including:
|
|
37
|
+
|
|
38
|
+
1. **Navigation**: Page loads and URL changes
|
|
39
|
+
2. **Input**: Text entry in form fields
|
|
40
|
+
3. **Selection**: Dropdown choices
|
|
41
|
+
4. **Clicks**: Button and link clicks
|
|
42
|
+
5. **Scrolling**: Page scroll events
|
|
43
|
+
6. **Mouse Movement**: Trajectory data for human-like behavior
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Example: Complete form submission workflow
|
|
47
|
+
agent-browser recorder start --session form-test
|
|
48
|
+
|
|
49
|
+
# Navigate to form
|
|
50
|
+
agent-browser open https://example.com/form
|
|
51
|
+
agent-browser snapshot -i
|
|
52
|
+
|
|
53
|
+
# Fill form fields
|
|
54
|
+
agent-browser fill @e1 "John Doe"
|
|
55
|
+
agent-browser fill @e2 "john@example.com"
|
|
56
|
+
agent-browser select @e3 "United States"
|
|
57
|
+
agent-browser check @e4
|
|
58
|
+
|
|
59
|
+
# Submit form
|
|
60
|
+
agent-browser click @e5
|
|
61
|
+
agent-browser wait --load networkidle
|
|
62
|
+
|
|
63
|
+
# Save recording
|
|
64
|
+
agent-browser recorder stop --output form-submission.yaml
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Supported Actions
|
|
68
|
+
|
|
69
|
+
| Action | Description | Example |
|
|
70
|
+
|--------|-------------|---------|
|
|
71
|
+
| `navigate` | Page navigation | `agent-browser open https://example.com` |
|
|
72
|
+
| `fill` | Text input | `agent-browser fill @e1 "text"` |
|
|
73
|
+
| `select` | Dropdown selection | `agent-browser select @e2 "option"` |
|
|
74
|
+
| `click` | Element click | `agent-browser click @e3` |
|
|
75
|
+
| `check` | Checkbox check | `agent-browser check @e4` |
|
|
76
|
+
| `uncheck` | Checkbox uncheck | `agent-browser uncheck @e5` |
|
|
77
|
+
| `scroll` | Page scroll | `agent-browser scroll down 500` |
|
|
78
|
+
| `trajectory` | Mouse movement | Captured automatically |
|
|
79
|
+
|
|
80
|
+
## YAML Output Format
|
|
81
|
+
|
|
82
|
+
The recorder generates a structured YAML file with:
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
session:
|
|
86
|
+
id: recorder-1234567890
|
|
87
|
+
startTime: 19:46:49
|
|
88
|
+
endTime: 19:48:28
|
|
89
|
+
steps: 83
|
|
90
|
+
|
|
91
|
+
pages:
|
|
92
|
+
- url: https://example.com
|
|
93
|
+
title: Example Domain
|
|
94
|
+
firstVisitTime: 19:46:53
|
|
95
|
+
|
|
96
|
+
steps:
|
|
97
|
+
- id: step-1234567890
|
|
98
|
+
time: 19:47:00
|
|
99
|
+
action: fill
|
|
100
|
+
selector: "#username"
|
|
101
|
+
xpath: "//*[@id='username']"
|
|
102
|
+
value: "testuser"
|
|
103
|
+
|
|
104
|
+
- id: step-1234567891
|
|
105
|
+
time: 19:47:05
|
|
106
|
+
action: click
|
|
107
|
+
selector: "#submit-btn"
|
|
108
|
+
xpath: "//*[@id='submit-btn']"
|
|
109
|
+
|
|
110
|
+
- id: step-1234567892
|
|
111
|
+
time: 19:47:10
|
|
112
|
+
action: scroll
|
|
113
|
+
x: 0
|
|
114
|
+
y: 500
|
|
115
|
+
|
|
116
|
+
# CLI Commands section contains executable commands
|
|
117
|
+
# for direct replay in terminal
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Replay Feature
|
|
121
|
+
|
|
122
|
+
Replay recorded interactions from YAML file:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Replay most recent recording
|
|
126
|
+
agent-browser recorder replay
|
|
127
|
+
|
|
128
|
+
# Replay specific file
|
|
129
|
+
agent-browser recorder replay form-submission.yaml
|
|
130
|
+
|
|
131
|
+
# Replay with verbose output
|
|
132
|
+
agent-browser recorder replay session.yaml --verbose
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The replay feature:
|
|
136
|
+
1. Parses the YAML file
|
|
137
|
+
2. Executes each step in sequence
|
|
138
|
+
3. Handles both navigation and interactions
|
|
139
|
+
4. Supports all recorded action types
|
|
140
|
+
|
|
141
|
+
## Use Cases
|
|
142
|
+
|
|
143
|
+
### 1. Test Automation Documentation
|
|
144
|
+
|
|
145
|
+
Record manual test sessions for documentation:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
agent-browser recorder start --session checkout-flow
|
|
149
|
+
|
|
150
|
+
# Perform checkout process
|
|
151
|
+
agent-browser open https://shop.example.com/cart
|
|
152
|
+
agent-browser snapshot -i
|
|
153
|
+
agent-browser fill @e1 "123 Main St"
|
|
154
|
+
agent-browser fill @e2 "New York"
|
|
155
|
+
agent-browser fill @e3 "10001"
|
|
156
|
+
agent-browser click @e4
|
|
157
|
+
agent-browser wait --load networkidle
|
|
158
|
+
|
|
159
|
+
# Save for documentation
|
|
160
|
+
agent-browser recorder stop --output docs/checkout-flow.yaml
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### 2. Regression Testing
|
|
164
|
+
|
|
165
|
+
Create reusable test scenarios:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Record once
|
|
169
|
+
agent-browser recorder start
|
|
170
|
+
agent-browser open https://app.example.com/login
|
|
171
|
+
agent-browser snapshot -i
|
|
172
|
+
agent-browser fill @e1 "$USERNAME"
|
|
173
|
+
agent-browser fill @e2 "$PASSWORD"
|
|
174
|
+
agent-browser click @e3
|
|
175
|
+
agent-browser recorder stop --output tests/login.yaml
|
|
176
|
+
|
|
177
|
+
# Replay in CI/CD
|
|
178
|
+
agent-browser recorder replay tests/login.yaml
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 3. Workflow Automation
|
|
182
|
+
|
|
183
|
+
Capture complex workflows for automation:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Record multi-step workflow
|
|
187
|
+
agent-browser recorder start
|
|
188
|
+
agent-browser open https://dashboard.example.com
|
|
189
|
+
agent-browser snapshot -i
|
|
190
|
+
agent-browser click @e1 # Navigate to reports
|
|
191
|
+
agent-browser click @e2 # Select date range
|
|
192
|
+
agent-browser click @e3 # Export CSV
|
|
193
|
+
agent-browser recorder stop --output workflows/export-data.yaml
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### 4. Debugging & Analysis
|
|
197
|
+
|
|
198
|
+
Record sessions for debugging:
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
agent-browser recorder start --session debug-$(date +%s)
|
|
202
|
+
|
|
203
|
+
# Run problematic workflow
|
|
204
|
+
agent-browser open https://example.com
|
|
205
|
+
# ... interactions ...
|
|
206
|
+
|
|
207
|
+
# Save for analysis
|
|
208
|
+
agent-browser recorder stop --output debug/session.yaml
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Best Practices
|
|
212
|
+
|
|
213
|
+
### 1. Use Session Names
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Good: Descriptive session names
|
|
217
|
+
agent-browser recorder start --session user-registration
|
|
218
|
+
agent-browser recorder start --session checkout-payment
|
|
219
|
+
agent-browser recorder start --session search-functionality
|
|
220
|
+
|
|
221
|
+
# Avoid: Generic names
|
|
222
|
+
agent-browser recorder start --session test1
|
|
223
|
+
agent-browser recorder start --session recording
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 2. Add Wait Times for Stability
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
agent-browser recorder start
|
|
230
|
+
|
|
231
|
+
# Add waits after critical actions
|
|
232
|
+
agent-browser click @e1
|
|
233
|
+
agent-browser wait --load networkidle # Wait for page load
|
|
234
|
+
|
|
235
|
+
agent-browser fill @e2 "text"
|
|
236
|
+
agent-browser wait 1000 # Wait for dynamic content
|
|
237
|
+
|
|
238
|
+
agent-browser click @e3
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 3. Use Snapshots for Ref Stability
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
agent-browser recorder start
|
|
245
|
+
|
|
246
|
+
# Always snapshot before interactions
|
|
247
|
+
agent-browser snapshot -i
|
|
248
|
+
agent-browser click @e1
|
|
249
|
+
|
|
250
|
+
# Re-snapshot after navigation
|
|
251
|
+
agent-browser wait --load networkidle
|
|
252
|
+
agent-browser snapshot -i
|
|
253
|
+
agent-browser click @e2
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### 4. Organize Recordings
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Create organized directory structure
|
|
260
|
+
recordings/
|
|
261
|
+
├── tests/
|
|
262
|
+
│ ├── login.yaml
|
|
263
|
+
│ ├── registration.yaml
|
|
264
|
+
│ └── checkout.yaml
|
|
265
|
+
├── workflows/
|
|
266
|
+
│ ├── data-export.yaml
|
|
267
|
+
│ └── report-generation.yaml
|
|
268
|
+
└── docs/
|
|
269
|
+
├── user-guide.yaml
|
|
270
|
+
└── api-demo.yaml
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### 5. Review Generated Commands
|
|
274
|
+
|
|
275
|
+
The YAML file includes a CLI Commands section at the end with executable commands. Review these commands to:
|
|
276
|
+
|
|
277
|
+
- Verify the captured selectors
|
|
278
|
+
- Check for redundant steps
|
|
279
|
+
- Identify opportunities for optimization
|
|
280
|
+
- Ensure actions are in correct order
|
|
281
|
+
|
|
282
|
+
## Advanced Features
|
|
283
|
+
|
|
284
|
+
### Session-Based Recording
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Record with specific session
|
|
288
|
+
agent-browser recorder start --session my-test --timeout 60000
|
|
289
|
+
|
|
290
|
+
# Use session for all commands
|
|
291
|
+
agent-browser open https://example.com --session my-test
|
|
292
|
+
agent-browser snapshot -i --session my-test
|
|
293
|
+
agent-browser click @e1 --session my-test
|
|
294
|
+
|
|
295
|
+
# Stop recording
|
|
296
|
+
agent-browser recorder stop --output my-test.yaml --session my-test
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Timeout Configuration
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
# Set recording timeout (default: 60 seconds)
|
|
303
|
+
agent-browser recorder start --timeout 120000 # 2 minutes
|
|
304
|
+
|
|
305
|
+
# Useful for long-running workflows
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Limitations
|
|
309
|
+
|
|
310
|
+
- Refs (`@e1`, `@e2`) are session-specific and not portable
|
|
311
|
+
- Convert to CSS selectors for cross-session reuse
|
|
312
|
+
- Some dynamic content may require additional wait handling
|
|
313
|
+
- Replay requires same page structure as recording
|
|
314
|
+
|
|
315
|
+
## See Also
|
|
316
|
+
|
|
317
|
+
- [snapshot-refs.md](snapshot-refs.md) - Understanding refs and their lifecycle
|
|
318
|
+
- [authentication.md](authentication.md) - Recording login flows
|
|
319
|
+
- [video-recording.md](video-recording.md) - Video recording for debugging
|