@kritchoff/agent-browser 0.9.2

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.
Files changed (88) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +903 -0
  3. package/README.sdk.md +77 -0
  4. package/bin/agent-browser-linux-x64 +0 -0
  5. package/bin/agent-browser.js +109 -0
  6. package/dist/actions.d.ts +17 -0
  7. package/dist/actions.d.ts.map +1 -0
  8. package/dist/actions.js +1427 -0
  9. package/dist/actions.js.map +1 -0
  10. package/dist/browser.d.ts +474 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +1566 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/cdp-client.d.ts +103 -0
  15. package/dist/cdp-client.d.ts.map +1 -0
  16. package/dist/cdp-client.js +223 -0
  17. package/dist/cdp-client.js.map +1 -0
  18. package/dist/daemon.d.ts +60 -0
  19. package/dist/daemon.d.ts.map +1 -0
  20. package/dist/daemon.js +401 -0
  21. package/dist/daemon.js.map +1 -0
  22. package/dist/dualmode-config.d.ts +37 -0
  23. package/dist/dualmode-config.d.ts.map +1 -0
  24. package/dist/dualmode-config.js +44 -0
  25. package/dist/dualmode-config.js.map +1 -0
  26. package/dist/dualmode-fetcher.d.ts +60 -0
  27. package/dist/dualmode-fetcher.d.ts.map +1 -0
  28. package/dist/dualmode-fetcher.js +449 -0
  29. package/dist/dualmode-fetcher.js.map +1 -0
  30. package/dist/dualmode-types.d.ts +183 -0
  31. package/dist/dualmode-types.d.ts.map +1 -0
  32. package/dist/dualmode-types.js +8 -0
  33. package/dist/dualmode-types.js.map +1 -0
  34. package/dist/ios-actions.d.ts +11 -0
  35. package/dist/ios-actions.d.ts.map +1 -0
  36. package/dist/ios-actions.js +228 -0
  37. package/dist/ios-actions.js.map +1 -0
  38. package/dist/ios-manager.d.ts +266 -0
  39. package/dist/ios-manager.d.ts.map +1 -0
  40. package/dist/ios-manager.js +1073 -0
  41. package/dist/ios-manager.js.map +1 -0
  42. package/dist/protocol.d.ts +26 -0
  43. package/dist/protocol.d.ts.map +1 -0
  44. package/dist/protocol.js +832 -0
  45. package/dist/protocol.js.map +1 -0
  46. package/dist/snapshot.d.ts +83 -0
  47. package/dist/snapshot.d.ts.map +1 -0
  48. package/dist/snapshot.js +653 -0
  49. package/dist/snapshot.js.map +1 -0
  50. package/dist/stream-server.d.ts +117 -0
  51. package/dist/stream-server.d.ts.map +1 -0
  52. package/dist/stream-server.js +305 -0
  53. package/dist/stream-server.js.map +1 -0
  54. package/dist/types.d.ts +742 -0
  55. package/dist/types.d.ts.map +1 -0
  56. package/dist/types.js +2 -0
  57. package/dist/types.js.map +1 -0
  58. package/docker-compose.sdk.yml +45 -0
  59. package/package.json +85 -0
  60. package/scripts/benchmark.sh +80 -0
  61. package/scripts/build-all-platforms.sh +68 -0
  62. package/scripts/check-version-sync.js +39 -0
  63. package/scripts/copy-native.js +36 -0
  64. package/scripts/fast_reset.sh +108 -0
  65. package/scripts/postinstall.js +235 -0
  66. package/scripts/publish_images.sh +55 -0
  67. package/scripts/snapshot_manager.sh +293 -0
  68. package/scripts/start-android-agent.sh +49 -0
  69. package/scripts/sync-version.js +69 -0
  70. package/scripts/vaccine-run +26 -0
  71. package/sdk.sh +153 -0
  72. package/skills/agent-browser/SKILL.md +217 -0
  73. package/skills/agent-browser/references/authentication.md +202 -0
  74. package/skills/agent-browser/references/commands.md +259 -0
  75. package/skills/agent-browser/references/proxy-support.md +188 -0
  76. package/skills/agent-browser/references/session-management.md +193 -0
  77. package/skills/agent-browser/references/snapshot-refs.md +194 -0
  78. package/skills/agent-browser/references/video-recording.md +173 -0
  79. package/skills/agent-browser/templates/authenticated-session.sh +97 -0
  80. package/skills/agent-browser/templates/capture-workflow.sh +69 -0
  81. package/skills/agent-browser/templates/form-automation.sh +62 -0
  82. package/skills/skill-creator/LICENSE.txt +202 -0
  83. package/skills/skill-creator/SKILL.md +356 -0
  84. package/skills/skill-creator/references/output-patterns.md +82 -0
  85. package/skills/skill-creator/references/workflows.md +28 -0
  86. package/skills/skill-creator/scripts/init_skill.py +303 -0
  87. package/skills/skill-creator/scripts/package_skill.py +113 -0
  88. package/skills/skill-creator/scripts/quick_validate.py +95 -0
@@ -0,0 +1,194 @@
1
+ # Snapshot and Refs
2
+
3
+ Compact element references that reduce context usage dramatically for AI agents.
4
+
5
+ **Related**: [commands.md](commands.md) for full command reference, [SKILL.md](../SKILL.md) for quick start.
6
+
7
+ ## Contents
8
+
9
+ - [How Refs Work](#how-refs-work)
10
+ - [Snapshot Command](#the-snapshot-command)
11
+ - [Using Refs](#using-refs)
12
+ - [Ref Lifecycle](#ref-lifecycle)
13
+ - [Best Practices](#best-practices)
14
+ - [Ref Notation Details](#ref-notation-details)
15
+ - [Troubleshooting](#troubleshooting)
16
+
17
+ ## How Refs Work
18
+
19
+ Traditional approach:
20
+ ```
21
+ Full DOM/HTML → AI parses → CSS selector → Action (~3000-5000 tokens)
22
+ ```
23
+
24
+ agent-browser approach:
25
+ ```
26
+ Compact snapshot → @refs assigned → Direct interaction (~200-400 tokens)
27
+ ```
28
+
29
+ ## The Snapshot Command
30
+
31
+ ```bash
32
+ # Basic snapshot (shows page structure)
33
+ agent-browser snapshot
34
+
35
+ # Interactive snapshot (-i flag) - RECOMMENDED
36
+ agent-browser snapshot -i
37
+ ```
38
+
39
+ ### Snapshot Output Format
40
+
41
+ ```
42
+ Page: Example Site - Home
43
+ URL: https://example.com
44
+
45
+ @e1 [header]
46
+ @e2 [nav]
47
+ @e3 [a] "Home"
48
+ @e4 [a] "Products"
49
+ @e5 [a] "About"
50
+ @e6 [button] "Sign In"
51
+
52
+ @e7 [main]
53
+ @e8 [h1] "Welcome"
54
+ @e9 [form]
55
+ @e10 [input type="email"] placeholder="Email"
56
+ @e11 [input type="password"] placeholder="Password"
57
+ @e12 [button type="submit"] "Log In"
58
+
59
+ @e13 [footer]
60
+ @e14 [a] "Privacy Policy"
61
+ ```
62
+
63
+ ## Using Refs
64
+
65
+ Once you have refs, interact directly:
66
+
67
+ ```bash
68
+ # Click the "Sign In" button
69
+ agent-browser click @e6
70
+
71
+ # Fill email input
72
+ agent-browser fill @e10 "user@example.com"
73
+
74
+ # Fill password
75
+ agent-browser fill @e11 "password123"
76
+
77
+ # Submit the form
78
+ agent-browser click @e12
79
+ ```
80
+
81
+ ## Ref Lifecycle
82
+
83
+ **IMPORTANT**: Refs are invalidated when the page changes!
84
+
85
+ ```bash
86
+ # Get initial snapshot
87
+ agent-browser snapshot -i
88
+ # @e1 [button] "Next"
89
+
90
+ # Click triggers page change
91
+ agent-browser click @e1
92
+
93
+ # MUST re-snapshot to get new refs!
94
+ agent-browser snapshot -i
95
+ # @e1 [h1] "Page 2" ← Different element now!
96
+ ```
97
+
98
+ ## Best Practices
99
+
100
+ ### 1. Always Snapshot Before Interacting
101
+
102
+ ```bash
103
+ # CORRECT
104
+ agent-browser open https://example.com
105
+ agent-browser snapshot -i # Get refs first
106
+ agent-browser click @e1 # Use ref
107
+
108
+ # WRONG
109
+ agent-browser open https://example.com
110
+ agent-browser click @e1 # Ref doesn't exist yet!
111
+ ```
112
+
113
+ ### 2. Re-Snapshot After Navigation
114
+
115
+ ```bash
116
+ agent-browser click @e5 # Navigates to new page
117
+ agent-browser snapshot -i # Get new refs
118
+ agent-browser click @e1 # Use new refs
119
+ ```
120
+
121
+ ### 3. Re-Snapshot After Dynamic Changes
122
+
123
+ ```bash
124
+ agent-browser click @e1 # Opens dropdown
125
+ agent-browser snapshot -i # See dropdown items
126
+ agent-browser click @e7 # Select item
127
+ ```
128
+
129
+ ### 4. Snapshot Specific Regions
130
+
131
+ For complex pages, snapshot specific areas:
132
+
133
+ ```bash
134
+ # Snapshot just the form
135
+ agent-browser snapshot @e9
136
+ ```
137
+
138
+ ## Ref Notation Details
139
+
140
+ ```
141
+ @e1 [tag type="value"] "text content" placeholder="hint"
142
+ │ │ │ │ │
143
+ │ │ │ │ └─ Additional attributes
144
+ │ │ │ └─ Visible text
145
+ │ │ └─ Key attributes shown
146
+ │ └─ HTML tag name
147
+ └─ Unique ref ID
148
+ ```
149
+
150
+ ### Common Patterns
151
+
152
+ ```
153
+ @e1 [button] "Submit" # Button with text
154
+ @e2 [input type="email"] # Email input
155
+ @e3 [input type="password"] # Password input
156
+ @e4 [a href="/page"] "Link Text" # Anchor link
157
+ @e5 [select] # Dropdown
158
+ @e6 [textarea] placeholder="Message" # Text area
159
+ @e7 [div class="modal"] # Container (when relevant)
160
+ @e8 [img alt="Logo"] # Image
161
+ @e9 [checkbox] checked # Checked checkbox
162
+ @e10 [radio] selected # Selected radio
163
+ ```
164
+
165
+ ## Troubleshooting
166
+
167
+ ### "Ref not found" Error
168
+
169
+ ```bash
170
+ # Ref may have changed - re-snapshot
171
+ agent-browser snapshot -i
172
+ ```
173
+
174
+ ### Element Not Visible in Snapshot
175
+
176
+ ```bash
177
+ # Scroll to reveal element
178
+ agent-browser scroll --bottom
179
+ agent-browser snapshot -i
180
+
181
+ # Or wait for dynamic content
182
+ agent-browser wait 1000
183
+ agent-browser snapshot -i
184
+ ```
185
+
186
+ ### Too Many Elements
187
+
188
+ ```bash
189
+ # Snapshot specific container
190
+ agent-browser snapshot @e5
191
+
192
+ # Or use get text for content-only extraction
193
+ agent-browser get text @e5
194
+ ```
@@ -0,0 +1,173 @@
1
+ # Video Recording
2
+
3
+ Capture browser automation as video for debugging, documentation, or verification.
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 Commands](#recording-commands)
11
+ - [Use Cases](#use-cases)
12
+ - [Best Practices](#best-practices)
13
+ - [Output Format](#output-format)
14
+ - [Limitations](#limitations)
15
+
16
+ ## Basic Recording
17
+
18
+ ```bash
19
+ # Start recording
20
+ agent-browser record start ./demo.webm
21
+
22
+ # Perform actions
23
+ agent-browser open https://example.com
24
+ agent-browser snapshot -i
25
+ agent-browser click @e1
26
+ agent-browser fill @e2 "test input"
27
+
28
+ # Stop and save
29
+ agent-browser record stop
30
+ ```
31
+
32
+ ## Recording Commands
33
+
34
+ ```bash
35
+ # Start recording to file
36
+ agent-browser record start ./output.webm
37
+
38
+ # Stop current recording
39
+ agent-browser record stop
40
+
41
+ # Restart with new file (stops current + starts new)
42
+ agent-browser record restart ./take2.webm
43
+ ```
44
+
45
+ ## Use Cases
46
+
47
+ ### Debugging Failed Automation
48
+
49
+ ```bash
50
+ #!/bin/bash
51
+ # Record automation for debugging
52
+
53
+ agent-browser record start ./debug-$(date +%Y%m%d-%H%M%S).webm
54
+
55
+ # Run your automation
56
+ agent-browser open https://app.example.com
57
+ agent-browser snapshot -i
58
+ agent-browser click @e1 || {
59
+ echo "Click failed - check recording"
60
+ agent-browser record stop
61
+ exit 1
62
+ }
63
+
64
+ agent-browser record stop
65
+ ```
66
+
67
+ ### Documentation Generation
68
+
69
+ ```bash
70
+ #!/bin/bash
71
+ # Record workflow for documentation
72
+
73
+ agent-browser record start ./docs/how-to-login.webm
74
+
75
+ agent-browser open https://app.example.com/login
76
+ agent-browser wait 1000 # Pause for visibility
77
+
78
+ agent-browser snapshot -i
79
+ agent-browser fill @e1 "demo@example.com"
80
+ agent-browser wait 500
81
+
82
+ agent-browser fill @e2 "password"
83
+ agent-browser wait 500
84
+
85
+ agent-browser click @e3
86
+ agent-browser wait --load networkidle
87
+ agent-browser wait 1000 # Show result
88
+
89
+ agent-browser record stop
90
+ ```
91
+
92
+ ### CI/CD Test Evidence
93
+
94
+ ```bash
95
+ #!/bin/bash
96
+ # Record E2E test runs for CI artifacts
97
+
98
+ TEST_NAME="${1:-e2e-test}"
99
+ RECORDING_DIR="./test-recordings"
100
+ mkdir -p "$RECORDING_DIR"
101
+
102
+ agent-browser record start "$RECORDING_DIR/$TEST_NAME-$(date +%s).webm"
103
+
104
+ # Run test
105
+ if run_e2e_test; then
106
+ echo "Test passed"
107
+ else
108
+ echo "Test failed - recording saved"
109
+ fi
110
+
111
+ agent-browser record stop
112
+ ```
113
+
114
+ ## Best Practices
115
+
116
+ ### 1. Add Pauses for Clarity
117
+
118
+ ```bash
119
+ # Slow down for human viewing
120
+ agent-browser click @e1
121
+ agent-browser wait 500 # Let viewer see result
122
+ ```
123
+
124
+ ### 2. Use Descriptive Filenames
125
+
126
+ ```bash
127
+ # Include context in filename
128
+ agent-browser record start ./recordings/login-flow-2024-01-15.webm
129
+ agent-browser record start ./recordings/checkout-test-run-42.webm
130
+ ```
131
+
132
+ ### 3. Handle Recording in Error Cases
133
+
134
+ ```bash
135
+ #!/bin/bash
136
+ set -e
137
+
138
+ cleanup() {
139
+ agent-browser record stop 2>/dev/null || true
140
+ agent-browser close 2>/dev/null || true
141
+ }
142
+ trap cleanup EXIT
143
+
144
+ agent-browser record start ./automation.webm
145
+ # ... automation steps ...
146
+ ```
147
+
148
+ ### 4. Combine with Screenshots
149
+
150
+ ```bash
151
+ # Record video AND capture key frames
152
+ agent-browser record start ./flow.webm
153
+
154
+ agent-browser open https://example.com
155
+ agent-browser screenshot ./screenshots/step1-homepage.png
156
+
157
+ agent-browser click @e1
158
+ agent-browser screenshot ./screenshots/step2-after-click.png
159
+
160
+ agent-browser record stop
161
+ ```
162
+
163
+ ## Output Format
164
+
165
+ - Default format: WebM (VP8/VP9 codec)
166
+ - Compatible with all modern browsers and video players
167
+ - Compressed but high quality
168
+
169
+ ## Limitations
170
+
171
+ - Recording adds slight overhead to automation
172
+ - Large recordings can consume significant disk space
173
+ - Some headless environments may have codec limitations
@@ -0,0 +1,97 @@
1
+ #!/bin/bash
2
+ # Template: Authenticated Session Workflow
3
+ # Purpose: Login once, save state, reuse for subsequent runs
4
+ # Usage: ./authenticated-session.sh <login-url> [state-file]
5
+ #
6
+ # Environment variables:
7
+ # APP_USERNAME - Login username/email
8
+ # APP_PASSWORD - Login password
9
+ #
10
+ # Two modes:
11
+ # 1. Discovery mode (default): Shows form structure so you can identify refs
12
+ # 2. Login mode: Performs actual login after you update the refs
13
+ #
14
+ # Setup steps:
15
+ # 1. Run once to see form structure (discovery mode)
16
+ # 2. Update refs in LOGIN FLOW section below
17
+ # 3. Set APP_USERNAME and APP_PASSWORD
18
+ # 4. Delete the DISCOVERY section
19
+
20
+ set -euo pipefail
21
+
22
+ LOGIN_URL="${1:?Usage: $0 <login-url> [state-file]}"
23
+ STATE_FILE="${2:-./auth-state.json}"
24
+
25
+ echo "Authentication workflow: $LOGIN_URL"
26
+
27
+ # ================================================================
28
+ # SAVED STATE: Skip login if valid saved state exists
29
+ # ================================================================
30
+ if [[ -f "$STATE_FILE" ]]; then
31
+ echo "Loading saved state from $STATE_FILE..."
32
+ agent-browser state load "$STATE_FILE"
33
+ agent-browser open "$LOGIN_URL"
34
+ agent-browser wait --load networkidle
35
+
36
+ CURRENT_URL=$(agent-browser get url)
37
+ if [[ "$CURRENT_URL" != *"login"* ]] && [[ "$CURRENT_URL" != *"signin"* ]]; then
38
+ echo "Session restored successfully"
39
+ agent-browser snapshot -i
40
+ exit 0
41
+ fi
42
+ echo "Session expired, performing fresh login..."
43
+ rm -f "$STATE_FILE"
44
+ fi
45
+
46
+ # ================================================================
47
+ # DISCOVERY MODE: Shows form structure (delete after setup)
48
+ # ================================================================
49
+ echo "Opening login page..."
50
+ agent-browser open "$LOGIN_URL"
51
+ agent-browser wait --load networkidle
52
+
53
+ echo ""
54
+ echo "Login form structure:"
55
+ echo "---"
56
+ agent-browser snapshot -i
57
+ echo "---"
58
+ echo ""
59
+ echo "Next steps:"
60
+ echo " 1. Note the refs: username=@e?, password=@e?, submit=@e?"
61
+ echo " 2. Update the LOGIN FLOW section below with your refs"
62
+ echo " 3. Set: export APP_USERNAME='...' APP_PASSWORD='...'"
63
+ echo " 4. Delete this DISCOVERY MODE section"
64
+ echo ""
65
+ agent-browser close
66
+ exit 0
67
+
68
+ # ================================================================
69
+ # LOGIN FLOW: Uncomment and customize after discovery
70
+ # ================================================================
71
+ # : "${APP_USERNAME:?Set APP_USERNAME environment variable}"
72
+ # : "${APP_PASSWORD:?Set APP_PASSWORD environment variable}"
73
+ #
74
+ # agent-browser open "$LOGIN_URL"
75
+ # agent-browser wait --load networkidle
76
+ # agent-browser snapshot -i
77
+ #
78
+ # # Fill credentials (update refs to match your form)
79
+ # agent-browser fill @e1 "$APP_USERNAME"
80
+ # agent-browser fill @e2 "$APP_PASSWORD"
81
+ # agent-browser click @e3
82
+ # agent-browser wait --load networkidle
83
+ #
84
+ # # Verify login succeeded
85
+ # FINAL_URL=$(agent-browser get url)
86
+ # if [[ "$FINAL_URL" == *"login"* ]] || [[ "$FINAL_URL" == *"signin"* ]]; then
87
+ # echo "Login failed - still on login page"
88
+ # agent-browser screenshot /tmp/login-failed.png
89
+ # agent-browser close
90
+ # exit 1
91
+ # fi
92
+ #
93
+ # # Save state for future runs
94
+ # echo "Saving state to $STATE_FILE"
95
+ # agent-browser state save "$STATE_FILE"
96
+ # echo "Login successful"
97
+ # agent-browser snapshot -i
@@ -0,0 +1,69 @@
1
+ #!/bin/bash
2
+ # Template: Content Capture Workflow
3
+ # Purpose: Extract content from web pages (text, screenshots, PDF)
4
+ # Usage: ./capture-workflow.sh <url> [output-dir]
5
+ #
6
+ # Outputs:
7
+ # - page-full.png: Full page screenshot
8
+ # - page-structure.txt: Page element structure with refs
9
+ # - page-text.txt: All text content
10
+ # - page.pdf: PDF version
11
+ #
12
+ # Optional: Load auth state for protected pages
13
+
14
+ set -euo pipefail
15
+
16
+ TARGET_URL="${1:?Usage: $0 <url> [output-dir]}"
17
+ OUTPUT_DIR="${2:-.}"
18
+
19
+ echo "Capturing: $TARGET_URL"
20
+ mkdir -p "$OUTPUT_DIR"
21
+
22
+ # Optional: Load authentication state
23
+ # if [[ -f "./auth-state.json" ]]; then
24
+ # echo "Loading authentication state..."
25
+ # agent-browser state load "./auth-state.json"
26
+ # fi
27
+
28
+ # Navigate to target
29
+ agent-browser open "$TARGET_URL"
30
+ agent-browser wait --load networkidle
31
+
32
+ # Get metadata
33
+ TITLE=$(agent-browser get title)
34
+ URL=$(agent-browser get url)
35
+ echo "Title: $TITLE"
36
+ echo "URL: $URL"
37
+
38
+ # Capture full page screenshot
39
+ agent-browser screenshot --full "$OUTPUT_DIR/page-full.png"
40
+ echo "Saved: $OUTPUT_DIR/page-full.png"
41
+
42
+ # Get page structure with refs
43
+ agent-browser snapshot -i > "$OUTPUT_DIR/page-structure.txt"
44
+ echo "Saved: $OUTPUT_DIR/page-structure.txt"
45
+
46
+ # Extract all text content
47
+ agent-browser get text body > "$OUTPUT_DIR/page-text.txt"
48
+ echo "Saved: $OUTPUT_DIR/page-text.txt"
49
+
50
+ # Save as PDF
51
+ agent-browser pdf "$OUTPUT_DIR/page.pdf"
52
+ echo "Saved: $OUTPUT_DIR/page.pdf"
53
+
54
+ # Optional: Extract specific elements using refs from structure
55
+ # agent-browser get text @e5 > "$OUTPUT_DIR/main-content.txt"
56
+
57
+ # Optional: Handle infinite scroll pages
58
+ # for i in {1..5}; do
59
+ # agent-browser scroll down 1000
60
+ # agent-browser wait 1000
61
+ # done
62
+ # agent-browser screenshot --full "$OUTPUT_DIR/page-scrolled.png"
63
+
64
+ # Cleanup
65
+ agent-browser close
66
+
67
+ echo ""
68
+ echo "Capture complete:"
69
+ ls -la "$OUTPUT_DIR"
@@ -0,0 +1,62 @@
1
+ #!/bin/bash
2
+ # Template: Form Automation Workflow
3
+ # Purpose: Fill and submit web forms with validation
4
+ # Usage: ./form-automation.sh <form-url>
5
+ #
6
+ # This template demonstrates the snapshot-interact-verify pattern:
7
+ # 1. Navigate to form
8
+ # 2. Snapshot to get element refs
9
+ # 3. Fill fields using refs
10
+ # 4. Submit and verify result
11
+ #
12
+ # Customize: Update the refs (@e1, @e2, etc.) based on your form's snapshot output
13
+
14
+ set -euo pipefail
15
+
16
+ FORM_URL="${1:?Usage: $0 <form-url>}"
17
+
18
+ echo "Form automation: $FORM_URL"
19
+
20
+ # Step 1: Navigate to form
21
+ agent-browser open "$FORM_URL"
22
+ agent-browser wait --load networkidle
23
+
24
+ # Step 2: Snapshot to discover form elements
25
+ echo ""
26
+ echo "Form structure:"
27
+ agent-browser snapshot -i
28
+
29
+ # Step 3: Fill form fields (customize these refs based on snapshot output)
30
+ #
31
+ # Common field types:
32
+ # agent-browser fill @e1 "John Doe" # Text input
33
+ # agent-browser fill @e2 "user@example.com" # Email input
34
+ # agent-browser fill @e3 "SecureP@ss123" # Password input
35
+ # agent-browser select @e4 "Option Value" # Dropdown
36
+ # agent-browser check @e5 # Checkbox
37
+ # agent-browser click @e6 # Radio button
38
+ # agent-browser fill @e7 "Multi-line text" # Textarea
39
+ # agent-browser upload @e8 /path/to/file.pdf # File upload
40
+ #
41
+ # Uncomment and modify:
42
+ # agent-browser fill @e1 "Test User"
43
+ # agent-browser fill @e2 "test@example.com"
44
+ # agent-browser click @e3 # Submit button
45
+
46
+ # Step 4: Wait for submission
47
+ # agent-browser wait --load networkidle
48
+ # agent-browser wait --url "**/success" # Or wait for redirect
49
+
50
+ # Step 5: Verify result
51
+ echo ""
52
+ echo "Result:"
53
+ agent-browser get url
54
+ agent-browser snapshot -i
55
+
56
+ # Optional: Capture evidence
57
+ agent-browser screenshot /tmp/form-result.png
58
+ echo "Screenshot saved: /tmp/form-result.png"
59
+
60
+ # Cleanup
61
+ agent-browser close
62
+ echo "Done"