cbrowser 5.1.0 → 5.2.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/README.md +299 -263
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +22 -0
- package/dist/browser.js.map +1 -1
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/docs/INSTALL.md +1 -1
- package/examples/basic-usage.ts +3 -1
- package/examples/smart-automation.ts +184 -0
- package/package.json +13 -7
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# CBrowser
|
|
2
2
|
|
|
3
|
-
**The browser that thinks.** AI-powered browser automation with
|
|
3
|
+
**The browser that thinks.** AI-powered browser automation with self-healing selectors, natural language assertions, constitutional safety, and autonomous journeys.
|
|
4
4
|
|
|
5
|
-
[](https://
|
|
5
|
+
[](https://www.npmjs.com/package/cbrowser)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
8
|
## What Makes This Different
|
|
@@ -10,421 +10,457 @@
|
|
|
10
10
|
| Traditional Automation | CBrowser |
|
|
11
11
|
|------------------------|----------|
|
|
12
12
|
| Brittle CSS selectors | AI vision: "click the blue login button" |
|
|
13
|
-
| Breaks when DOM changes | Self-healing
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
13
|
+
| Breaks when DOM changes | **Self-healing selectors** adapt automatically |
|
|
14
|
+
| Crashes on element not found | **Smart retry** finds alternatives |
|
|
15
|
+
| Manual test assertions | **Natural language assertions** |
|
|
16
|
+
| Scripted tests only | **AI test generation** from page analysis |
|
|
17
|
+
| Stateless between runs | Persistent sessions, cookies, localStorage |
|
|
17
18
|
| No user context | Personas with goals, behaviors, limitations |
|
|
18
|
-
|
|
|
19
|
-
| Scripted tests only | Autonomous goal-driven journeys |
|
|
19
|
+
| Standalone tool | **MCP Server** for Claude integration |
|
|
20
20
|
|
|
21
21
|
## Quick Start
|
|
22
22
|
|
|
23
23
|
### Installation
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
#
|
|
26
|
+
# npm
|
|
27
27
|
npm install cbrowser
|
|
28
28
|
|
|
29
|
-
#
|
|
29
|
+
# bun (recommended)
|
|
30
30
|
bun add cbrowser
|
|
31
31
|
|
|
32
|
-
#
|
|
32
|
+
# yarn
|
|
33
33
|
yarn add cbrowser
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
### Install Playwright Browsers
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
# Install Chromium (default)
|
|
40
39
|
npx playwright install chromium
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Basic Usage
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Navigate to a URL
|
|
46
|
+
npx cbrowser navigate "https://example.com"
|
|
47
|
+
|
|
48
|
+
# Click with auto-retry and self-healing
|
|
49
|
+
npx cbrowser smart-click "Add to Cart"
|
|
41
50
|
|
|
42
|
-
#
|
|
43
|
-
npx
|
|
51
|
+
# Natural language assertions
|
|
52
|
+
npx cbrowser assert "page contains 'Welcome'"
|
|
53
|
+
|
|
54
|
+
# Generate tests from any page
|
|
55
|
+
npx cbrowser generate-tests "https://example.com"
|
|
44
56
|
```
|
|
45
57
|
|
|
46
|
-
|
|
58
|
+
## v5.0.0 Features
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
### Smart Click with Auto-Retry
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
62
|
+
When an element isn't found, CBrowser automatically:
|
|
63
|
+
1. Checks the self-healing cache for known alternatives
|
|
64
|
+
2. Generates alternative selectors (text variants, ARIA roles, attributes)
|
|
65
|
+
3. Tries each alternative with configurable retry logic
|
|
66
|
+
4. Caches working selectors for future use
|
|
55
67
|
|
|
56
68
|
```bash
|
|
57
|
-
#
|
|
58
|
-
npx cbrowser
|
|
69
|
+
# Smart click with retry
|
|
70
|
+
npx cbrowser smart-click "Submit" --max-retries 5
|
|
59
71
|
|
|
60
|
-
#
|
|
61
|
-
npx cbrowser
|
|
72
|
+
# Navigate then click
|
|
73
|
+
npx cbrowser smart-click "Login" --url "https://example.com"
|
|
74
|
+
```
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
```typescript
|
|
77
|
+
import { CBrowser } from 'cbrowser';
|
|
78
|
+
|
|
79
|
+
const browser = new CBrowser();
|
|
80
|
+
const result = await browser.smartClick("Submit Button", { maxRetries: 3 });
|
|
81
|
+
|
|
82
|
+
console.log(result.success); // true/false
|
|
83
|
+
console.log(result.finalSelector); // The selector that worked
|
|
84
|
+
console.log(result.attempts); // Array of all attempts
|
|
85
|
+
console.log(result.aiSuggestion); // AI suggestion if failed
|
|
66
86
|
```
|
|
67
87
|
|
|
68
|
-
###
|
|
88
|
+
### Natural Language Assertions
|
|
89
|
+
|
|
90
|
+
Write assertions in plain English:
|
|
69
91
|
|
|
70
92
|
```bash
|
|
71
|
-
#
|
|
72
|
-
npx cbrowser
|
|
93
|
+
# Title assertions
|
|
94
|
+
npx cbrowser assert "title contains 'Dashboard'"
|
|
95
|
+
npx cbrowser assert "title is 'Home Page'"
|
|
96
|
+
|
|
97
|
+
# URL assertions
|
|
98
|
+
npx cbrowser assert "url contains '/login'"
|
|
73
99
|
|
|
74
|
-
#
|
|
75
|
-
npx cbrowser
|
|
100
|
+
# Content assertions
|
|
101
|
+
npx cbrowser assert "page contains 'Welcome back'"
|
|
76
102
|
|
|
77
|
-
#
|
|
78
|
-
npx cbrowser
|
|
103
|
+
# Element assertions
|
|
104
|
+
npx cbrowser assert "'#submit-btn' exists"
|
|
79
105
|
|
|
80
|
-
#
|
|
81
|
-
npx cbrowser
|
|
106
|
+
# Count assertions
|
|
107
|
+
npx cbrowser assert "5 buttons"
|
|
108
|
+
npx cbrowser assert "3 links"
|
|
82
109
|
```
|
|
83
110
|
|
|
84
|
-
|
|
111
|
+
```typescript
|
|
112
|
+
const result = await browser.assert("page contains 'Success'");
|
|
113
|
+
console.log(result.passed); // true/false
|
|
114
|
+
console.log(result.message); // Human-readable result
|
|
115
|
+
console.log(result.actual); // What was found
|
|
116
|
+
console.log(result.expected); // What was expected
|
|
117
|
+
```
|
|
85
118
|
|
|
86
|
-
###
|
|
119
|
+
### Self-Healing Selector Cache
|
|
87
120
|
|
|
88
|
-
|
|
121
|
+
CBrowser remembers which selectors work on each domain:
|
|
89
122
|
|
|
90
123
|
```bash
|
|
91
|
-
#
|
|
92
|
-
cbrowser
|
|
93
|
-
cbrowser fill "password field" "secret123"
|
|
124
|
+
# View cache statistics
|
|
125
|
+
npx cbrowser heal-stats
|
|
94
126
|
|
|
95
|
-
#
|
|
96
|
-
cbrowser
|
|
97
|
-
|
|
98
|
-
# Visual description
|
|
99
|
-
cbrowser click "visual:red button in header"
|
|
100
|
-
|
|
101
|
-
# Semantic type
|
|
102
|
-
cbrowser fill "semantic:email" "user@example.com"
|
|
127
|
+
# Clear the cache
|
|
128
|
+
npx cbrowser heal-clear
|
|
129
|
+
```
|
|
103
130
|
|
|
104
|
-
|
|
105
|
-
|
|
131
|
+
```typescript
|
|
132
|
+
const stats = browser.getSelectorCacheStats();
|
|
133
|
+
console.log(stats.totalEntries); // 42
|
|
134
|
+
console.log(stats.totalSuccesses); // 156
|
|
135
|
+
console.log(stats.topDomains); // [{ domain: 'example.com', count: 15 }, ...]
|
|
106
136
|
```
|
|
107
137
|
|
|
108
|
-
###
|
|
138
|
+
### AI Test Generation
|
|
109
139
|
|
|
110
|
-
|
|
140
|
+
Analyze any page and generate test scenarios automatically:
|
|
111
141
|
|
|
112
142
|
```bash
|
|
113
|
-
#
|
|
114
|
-
cbrowser
|
|
143
|
+
# Generate tests for a page
|
|
144
|
+
npx cbrowser generate-tests "https://example.com"
|
|
115
145
|
|
|
116
|
-
#
|
|
117
|
-
cbrowser
|
|
146
|
+
# Output specific format
|
|
147
|
+
npx cbrowser generate-tests "https://example.com" --format playwright
|
|
148
|
+
npx cbrowser generate-tests "https://example.com" --format cbrowser
|
|
118
149
|
|
|
119
|
-
#
|
|
120
|
-
cbrowser
|
|
150
|
+
# Save to file
|
|
151
|
+
npx cbrowser generate-tests "https://example.com" --output tests.ts
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
const result = await browser.generateTests("https://example.com");
|
|
121
156
|
|
|
122
|
-
|
|
123
|
-
|
|
157
|
+
console.log(result.analysis); // Page structure analysis
|
|
158
|
+
console.log(result.tests); // Generated test scenarios
|
|
159
|
+
console.log(result.playwrightCode); // Playwright test code
|
|
160
|
+
console.log(result.cbrowserScript); // CBrowser CLI script
|
|
124
161
|
```
|
|
125
162
|
|
|
126
|
-
|
|
163
|
+
**Example generated test:**
|
|
164
|
+
```typescript
|
|
165
|
+
test('Login - Valid Credentials', async ({ page }) => {
|
|
166
|
+
await page.goto('https://example.com');
|
|
167
|
+
await page.locator('[name="email"]').fill('test@example.com');
|
|
168
|
+
await page.locator('[name="password"]').fill('password123');
|
|
169
|
+
await page.locator('button[type="submit"]').click();
|
|
170
|
+
await expect(page).toHaveURL(/dashboard/);
|
|
171
|
+
});
|
|
172
|
+
```
|
|
127
173
|
|
|
128
|
-
|
|
174
|
+
### Page Analysis
|
|
129
175
|
|
|
130
|
-
|
|
131
|
-
# Run an autonomous journey as a specific persona
|
|
132
|
-
cbrowser journey "first-timer" \
|
|
133
|
-
--start "https://mysite.com" \
|
|
134
|
-
--goal "Complete signup and reach dashboard"
|
|
176
|
+
Understand any page's structure:
|
|
135
177
|
|
|
136
|
-
|
|
137
|
-
cbrowser
|
|
178
|
+
```bash
|
|
179
|
+
npx cbrowser analyze "https://example.com"
|
|
138
180
|
```
|
|
139
181
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
182
|
+
Output:
|
|
183
|
+
```
|
|
184
|
+
📊 Page Analysis:
|
|
185
|
+
Title: Example Domain
|
|
186
|
+
Forms: 1
|
|
187
|
+
- form#login (3 fields)
|
|
188
|
+
🔐 Login form detected
|
|
189
|
+
Buttons: 5
|
|
190
|
+
Links: 12
|
|
191
|
+
Has Login: ✅
|
|
192
|
+
Has Search: ❌
|
|
193
|
+
Has Navigation: ✅
|
|
194
|
+
```
|
|
150
195
|
|
|
151
|
-
###
|
|
196
|
+
### MCP Server Mode
|
|
152
197
|
|
|
153
|
-
|
|
198
|
+
Run CBrowser as an MCP server for Claude Desktop integration:
|
|
154
199
|
|
|
155
200
|
```bash
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
--username "me@email.com" \
|
|
159
|
-
--password "my-secret-password"
|
|
201
|
+
npx cbrowser mcp-server
|
|
202
|
+
```
|
|
160
203
|
|
|
161
|
-
|
|
162
|
-
cbrowser creds list
|
|
204
|
+
Add to Claude Desktop config (`~/.config/claude-desktop/config.json`):
|
|
163
205
|
|
|
164
|
-
|
|
165
|
-
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"mcpServers": {
|
|
209
|
+
"cbrowser": {
|
|
210
|
+
"command": "npx",
|
|
211
|
+
"args": ["cbrowser", "mcp-server"]
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
166
215
|
```
|
|
167
216
|
|
|
168
|
-
|
|
217
|
+
**Available MCP Tools:**
|
|
218
|
+
- `navigate` - Navigate to URL and screenshot
|
|
219
|
+
- `click` / `smart_click` - Click elements
|
|
220
|
+
- `fill` - Fill form fields
|
|
221
|
+
- `screenshot` - Capture page
|
|
222
|
+
- `extract` - Extract page data
|
|
223
|
+
- `assert` - Natural language assertions
|
|
224
|
+
- `analyze_page` - Analyze page structure
|
|
225
|
+
- `generate_tests` - Generate test scenarios
|
|
226
|
+
- `save_session` / `load_session` - Session management
|
|
227
|
+
- `heal_stats` - Self-healing cache stats
|
|
228
|
+
|
|
229
|
+
## Core Features
|
|
169
230
|
|
|
170
|
-
|
|
231
|
+
### AI-Powered Element Selection
|
|
171
232
|
|
|
172
233
|
```bash
|
|
173
|
-
#
|
|
174
|
-
cbrowser
|
|
234
|
+
# Natural language
|
|
235
|
+
cbrowser click "the main navigation menu"
|
|
236
|
+
cbrowser fill "password field" "secret123"
|
|
175
237
|
|
|
176
|
-
#
|
|
177
|
-
cbrowser
|
|
238
|
+
# Accessibility-based
|
|
239
|
+
cbrowser click "aria:button/Submit"
|
|
178
240
|
|
|
179
|
-
#
|
|
180
|
-
cbrowser
|
|
241
|
+
# Visual description
|
|
242
|
+
cbrowser click "visual:red button in header"
|
|
181
243
|
|
|
182
|
-
#
|
|
183
|
-
cbrowser
|
|
184
|
-
```
|
|
244
|
+
# Semantic type
|
|
245
|
+
cbrowser fill "semantic:email" "user@example.com"
|
|
185
246
|
|
|
186
|
-
|
|
247
|
+
# Fallback to CSS
|
|
248
|
+
cbrowser click "css:#login-btn"
|
|
249
|
+
```
|
|
187
250
|
|
|
188
|
-
|
|
251
|
+
### Session Persistence
|
|
189
252
|
|
|
190
253
|
```bash
|
|
191
|
-
#
|
|
192
|
-
cbrowser
|
|
254
|
+
# Save session (cookies, localStorage, sessionStorage)
|
|
255
|
+
cbrowser session save "logged-in" --url "https://example.com"
|
|
193
256
|
|
|
194
|
-
#
|
|
195
|
-
cbrowser
|
|
257
|
+
# Load session
|
|
258
|
+
cbrowser session load "logged-in"
|
|
196
259
|
|
|
197
|
-
#
|
|
198
|
-
cbrowser
|
|
260
|
+
# List sessions
|
|
261
|
+
cbrowser session list
|
|
199
262
|
```
|
|
200
263
|
|
|
201
|
-
|
|
264
|
+
### Persistent Browser Context
|
|
265
|
+
|
|
266
|
+
Enable persistent mode to keep cookies and localStorage between CLI calls:
|
|
202
267
|
|
|
203
|
-
|
|
268
|
+
```bash
|
|
269
|
+
npx cbrowser navigate "https://example.com" --persistent
|
|
270
|
+
```
|
|
204
271
|
|
|
205
|
-
|
|
272
|
+
### Persona-Driven Testing
|
|
206
273
|
|
|
207
274
|
```bash
|
|
208
|
-
#
|
|
209
|
-
|
|
275
|
+
# Run autonomous journey as a persona
|
|
276
|
+
cbrowser journey "first-timer" \
|
|
277
|
+
--start "https://mysite.com" \
|
|
278
|
+
--goal "Complete signup"
|
|
210
279
|
|
|
211
|
-
#
|
|
212
|
-
|
|
280
|
+
# List personas
|
|
281
|
+
cbrowser persona list
|
|
213
282
|
```
|
|
214
283
|
|
|
215
|
-
|
|
284
|
+
**Built-in Personas:**
|
|
216
285
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
286
|
+
| Persona | Description |
|
|
287
|
+
|---------|-------------|
|
|
288
|
+
| `power-user` | Tech-savvy, expects efficiency |
|
|
289
|
+
| `first-timer` | New user, slow and exploratory |
|
|
290
|
+
| `mobile-user` | Touch interface, small screen |
|
|
291
|
+
| `elderly-user` | Vision/motor limitations |
|
|
292
|
+
| `impatient-user` | Quick to abandon |
|
|
293
|
+
|
|
294
|
+
### Multi-Browser Support
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
# Firefox
|
|
298
|
+
npx cbrowser navigate "https://example.com" --browser firefox
|
|
299
|
+
|
|
300
|
+
# WebKit (Safari)
|
|
301
|
+
npx cbrowser navigate "https://example.com" --browser webkit
|
|
226
302
|
```
|
|
227
303
|
|
|
228
|
-
|
|
304
|
+
### Device Emulation
|
|
229
305
|
|
|
230
|
-
|
|
306
|
+
```bash
|
|
307
|
+
# Mobile
|
|
308
|
+
npx cbrowser navigate "https://example.com" --device iphone-15
|
|
231
309
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
| **Green** | Navigate, read, screenshot, scroll | Auto-execute |
|
|
235
|
-
| **Yellow** | Click buttons, fill forms, select | Log and proceed |
|
|
236
|
-
| **Red** | Submit, delete, purchase, account changes | Requires `--force` |
|
|
237
|
-
| **Black** | Bypass auth, violate ToS, inject scripts | Never execute |
|
|
310
|
+
# Tablet
|
|
311
|
+
npx cbrowser navigate "https://example.com" --device ipad-pro-12
|
|
238
312
|
|
|
239
|
-
|
|
313
|
+
# List devices
|
|
314
|
+
npx cbrowser device list
|
|
315
|
+
```
|
|
240
316
|
|
|
241
|
-
|
|
317
|
+
### Performance Metrics
|
|
242
318
|
|
|
243
319
|
```bash
|
|
244
|
-
|
|
320
|
+
# Core Web Vitals
|
|
321
|
+
npx cbrowser perf "https://example.com"
|
|
322
|
+
|
|
323
|
+
# With budget
|
|
324
|
+
npx cbrowser perf audit "https://example.com" --budget-lcp 2500
|
|
245
325
|
```
|
|
246
326
|
|
|
247
327
|
## API Usage
|
|
248
328
|
|
|
249
|
-
Use CBrowser programmatically:
|
|
250
|
-
|
|
251
329
|
```typescript
|
|
252
330
|
import { CBrowser } from 'cbrowser';
|
|
253
331
|
|
|
254
332
|
const browser = new CBrowser({
|
|
255
|
-
dataDir: './my-data',
|
|
256
333
|
headless: true,
|
|
334
|
+
persistent: true, // Persist cookies between sessions
|
|
257
335
|
});
|
|
258
336
|
|
|
337
|
+
// Navigate
|
|
259
338
|
await browser.navigate('https://example.com');
|
|
260
|
-
await browser.click('Sign In');
|
|
261
|
-
await browser.fill('email', 'user@example.com');
|
|
262
|
-
await browser.fill('password', 'secret123');
|
|
263
|
-
await browser.click('Submit');
|
|
264
|
-
|
|
265
|
-
const screenshot = await browser.screenshot();
|
|
266
|
-
await browser.close();
|
|
267
|
-
```
|
|
268
339
|
|
|
269
|
-
|
|
340
|
+
// Smart click with retry
|
|
341
|
+
const clickResult = await browser.smartClick('Sign In');
|
|
270
342
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const browser = new CBrowser();
|
|
343
|
+
// Fill form
|
|
344
|
+
await browser.fill('email', 'user@example.com');
|
|
275
345
|
|
|
276
|
-
//
|
|
277
|
-
const
|
|
278
|
-
if (!
|
|
279
|
-
|
|
280
|
-
await browser.fill('email', 'user@example.com');
|
|
281
|
-
await browser.fill('password', 'secret');
|
|
282
|
-
await browser.click('Login');
|
|
283
|
-
await browser.saveSession('my-app');
|
|
346
|
+
// Assert
|
|
347
|
+
const assertion = await browser.assert("page contains 'Welcome'");
|
|
348
|
+
if (!assertion.passed) {
|
|
349
|
+
console.error(assertion.message);
|
|
284
350
|
}
|
|
285
351
|
|
|
286
|
-
//
|
|
287
|
-
await browser.
|
|
352
|
+
// Generate tests
|
|
353
|
+
const tests = await browser.generateTests();
|
|
354
|
+
console.log(tests.playwrightCode);
|
|
355
|
+
|
|
356
|
+
// Cleanup
|
|
357
|
+
await browser.close();
|
|
288
358
|
```
|
|
289
359
|
|
|
290
|
-
|
|
360
|
+
## Configuration
|
|
291
361
|
|
|
292
|
-
|
|
293
|
-
import { CBrowser } from 'cbrowser';
|
|
362
|
+
### Environment Variables
|
|
294
363
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
});
|
|
364
|
+
| Variable | Default | Description |
|
|
365
|
+
|----------|---------|-------------|
|
|
366
|
+
| `CBROWSER_DATA_DIR` | `~/.cbrowser` | Data storage directory |
|
|
367
|
+
| `CBROWSER_HEADLESS` | `true` | Run headless (set to `false` for GUI) |
|
|
368
|
+
| `CBROWSER_BROWSER` | `chromium` | Browser engine |
|
|
369
|
+
| `CBROWSER_TIMEOUT` | `30000` | Default timeout (ms) |
|
|
302
370
|
|
|
303
|
-
|
|
304
|
-
console.log('Friction points:', result.frictionPoints);
|
|
305
|
-
console.log('Console logs:', result.consoleLogs);
|
|
306
|
-
```
|
|
371
|
+
### Config File
|
|
307
372
|
|
|
308
|
-
|
|
373
|
+
Create `.cbrowserrc.json`:
|
|
309
374
|
|
|
310
|
-
|
|
375
|
+
```json
|
|
376
|
+
{
|
|
377
|
+
"headless": true,
|
|
378
|
+
"timeout": 60000,
|
|
379
|
+
"persistent": true,
|
|
380
|
+
"viewport": {
|
|
381
|
+
"width": 1920,
|
|
382
|
+
"height": 1080
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
```
|
|
311
386
|
|
|
312
|
-
|
|
313
|
-
// tests/checkout.test.ts
|
|
314
|
-
import { CBrowser } from 'cbrowser';
|
|
387
|
+
## Constitutional Safety
|
|
315
388
|
|
|
316
|
-
|
|
317
|
-
let browser: CBrowser;
|
|
389
|
+
CBrowser classifies actions by risk level:
|
|
318
390
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
391
|
+
| Zone | Actions | Behavior |
|
|
392
|
+
|------|---------|----------|
|
|
393
|
+
| **Green** | Navigate, read, screenshot | Auto-execute |
|
|
394
|
+
| **Yellow** | Click, fill forms | Log and proceed |
|
|
395
|
+
| **Red** | Submit, delete, purchase | Requires `--force` |
|
|
396
|
+
| **Black** | Bypass auth, inject scripts | Never execute |
|
|
323
397
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
398
|
+
```bash
|
|
399
|
+
# Bypass safety for testing
|
|
400
|
+
cbrowser click "Delete Account" --force
|
|
401
|
+
```
|
|
327
402
|
|
|
328
|
-
|
|
329
|
-
await browser.navigate('https://shop.example.com/products');
|
|
330
|
-
await browser.click('Add to Cart');
|
|
331
|
-
await browser.click('View Cart');
|
|
403
|
+
## Performance
|
|
332
404
|
|
|
333
|
-
|
|
334
|
-
expect(cartItems.length).toBeGreaterThan(0);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
```
|
|
405
|
+
CBrowser uses optimized Chromium launch flags for fast startup:
|
|
338
406
|
|
|
339
|
-
|
|
407
|
+
- **~1 second** browser cold start (vs 3-5s default)
|
|
408
|
+
- **Persistent context** keeps cookies between calls
|
|
409
|
+
- **Self-healing cache** reduces retry overhead
|
|
340
410
|
|
|
341
|
-
|
|
342
|
-
import { CBrowser } from 'cbrowser';
|
|
411
|
+
## Examples
|
|
343
412
|
|
|
344
|
-
|
|
345
|
-
const results = [];
|
|
346
|
-
|
|
347
|
-
for (const persona of personas) {
|
|
348
|
-
const browser = new CBrowser();
|
|
349
|
-
const result = await browser.journey({
|
|
350
|
-
persona,
|
|
351
|
-
startUrl: 'https://example.com',
|
|
352
|
-
goal: 'Complete checkout',
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
results.push({
|
|
356
|
-
persona,
|
|
357
|
-
success: result.success,
|
|
358
|
-
timeMs: result.totalTime,
|
|
359
|
-
frictionPoints: result.frictionPoints,
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
await browser.close();
|
|
363
|
-
}
|
|
413
|
+
See the [`examples/`](examples/) directory:
|
|
364
414
|
|
|
365
|
-
|
|
366
|
-
|
|
415
|
+
- `basic-usage.ts` - Navigation, extraction, sessions
|
|
416
|
+
- `smart-automation.ts` - Smart click, assertions, test generation
|
|
417
|
+
- `journeys/checkout-flow.json` - Persona journey definition
|
|
418
|
+
- `personas/custom-persona.json` - Custom persona template
|
|
367
419
|
|
|
368
420
|
## Troubleshooting
|
|
369
421
|
|
|
370
422
|
### Browser Not Starting
|
|
371
423
|
|
|
372
424
|
```bash
|
|
373
|
-
|
|
374
|
-
npx playwright install chromium
|
|
375
|
-
|
|
376
|
-
# Check for display issues (Linux servers)
|
|
377
|
-
export DISPLAY=:0
|
|
378
|
-
# Or run headless
|
|
379
|
-
cbrowser navigate "https://example.com" --headless
|
|
425
|
+
npx playwright install chromium --force
|
|
380
426
|
```
|
|
381
427
|
|
|
382
|
-
###
|
|
428
|
+
### Display Issues (Linux)
|
|
383
429
|
|
|
384
|
-
|
|
430
|
+
CBrowser runs headless by default. For GUI mode:
|
|
385
431
|
|
|
386
432
|
```bash
|
|
387
|
-
|
|
388
|
-
cbrowser session save "my-session" --url "https://example.com"
|
|
389
|
-
|
|
390
|
-
# Load must also be on example.com
|
|
391
|
-
cbrowser session load "my-session"
|
|
392
|
-
# This navigates to the saved URL automatically
|
|
433
|
+
CBROWSER_HEADLESS=false npx cbrowser navigate "https://example.com"
|
|
393
434
|
```
|
|
394
435
|
|
|
395
|
-
###
|
|
436
|
+
### Self-Healing Not Working
|
|
396
437
|
|
|
397
|
-
|
|
438
|
+
```bash
|
|
439
|
+
# Check cache status
|
|
440
|
+
npx cbrowser heal-stats
|
|
398
441
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
442
|
+
# Clear if corrupted
|
|
443
|
+
npx cbrowser heal-clear
|
|
444
|
+
```
|
|
402
445
|
|
|
403
446
|
## Contributing
|
|
404
447
|
|
|
405
|
-
Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
406
|
-
|
|
407
448
|
```bash
|
|
408
|
-
|
|
409
|
-
git clone https://github.com/yourusername/cbrowser.git
|
|
449
|
+
git clone https://github.com/wyld-digital/cbrowser.git
|
|
410
450
|
cd cbrowser
|
|
411
|
-
|
|
412
|
-
# Install dependencies
|
|
413
451
|
bun install
|
|
414
|
-
|
|
415
|
-
# Run in development
|
|
416
452
|
bun run dev
|
|
417
|
-
|
|
418
|
-
# Run tests
|
|
419
|
-
bun test
|
|
420
453
|
```
|
|
421
454
|
|
|
455
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
456
|
+
|
|
422
457
|
## License
|
|
423
458
|
|
|
424
|
-
MIT - see [LICENSE](LICENSE)
|
|
459
|
+
MIT - see [LICENSE](LICENSE)
|
|
425
460
|
|
|
426
|
-
##
|
|
461
|
+
## Links
|
|
427
462
|
|
|
428
|
-
-
|
|
429
|
-
-
|
|
430
|
-
-
|
|
463
|
+
- [NPM Package](https://www.npmjs.com/package/cbrowser)
|
|
464
|
+
- [GitHub Repository](https://github.com/wyld-digital/cbrowser)
|
|
465
|
+
- [Issue Tracker](https://github.com/wyld-digital/cbrowser/issues)
|
|
466
|
+
- [Roadmap](ROADMAP.md)
|