A lightweight browser automation toolkit using Chrome DevTools Protocol (CDP). No Playwright or Puppeteer dependencies - just raw WebSocket communication with Chrome.
- Zero heavy dependencies - Only requires
ws(WebSocket client) - React-compatible - Works with controlled inputs using native value setters
- Screenshot automation - Capture at multiple viewports with one command
- Configurable - Project-specific selectors via
qa.config.js - Claude Code integration - Includes personas for AI-assisted QA workflows
# Copy to your project
cp -r cdp-qa-toolkit/qa your-project/qa
cp cdp-qa-toolkit/qa.config.example.js your-project/qa.config.js
# Install dependency
npm install wsOr add to your package.json:
{
"scripts": {
"qa": "node qa/cdp-qa.js",
"qa:responsive": "node qa/cdp-qa.js responsive",
"qa:mobile": "node qa/cdp-qa.js screenshot mobile",
"qa:desktop": "node qa/cdp-qa.js screenshot desktop"
},
"devDependencies": {
"ws": "^8.18.0"
}
}# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
# Windows
chrome.exe --remote-debugging-port=9222
# Linux
google-chrome --remote-debugging-port=9222npm run qa statusnpm run qa screenshot mobile # 375x812
npm run qa screenshot tablet # 768x1024
npm run qa screenshot desktop # 1920x1080
npm run qa screenshot 1440 900 # Custom size
npm run qa responsive # All breakpoints at oncenpm run qa navigate /dashboard
npm run qa click "[data-testid='submit-btn']"
npm run qa type "input[name='email']" "test@example.com"
npm run qa select "#country" "US"
npm run qa wait "[data-testid='loaded']"
npm run qa eval "document.title"npm run qa modal wait # Wait for modal to appear
npm run qa modal fill "#name" "John"
npm run qa modal select "#plan" "pro"
npm run qa modal submit
npm run qa modal closenpm run qa status # Check Chrome connection
npm run qa audit # Page stats (DOM elements, forms, etc.)
npm run qa console # Stream console.log outputCreate qa.config.js in your project root:
module.exports = {
// Chrome debugging URL
cdpUrl: 'http://127.0.0.1:9222',
// Screenshot output directory
screenshotDir: './qa-screenshots',
// Custom viewports
viewports: {
mobile: { width: 375, height: 812, mobile: true },
tablet: { width: 768, height: 1024, mobile: true },
desktop: { width: 1920, height: 1080, mobile: false },
},
// Project-specific selectors
selectors: {
modal: '[role="dialog"]',
modalClose: '[data-testid="modal-close"]',
submitButton: 'button[type="submit"]',
},
};This toolkit includes Claude Code personas for AI-assisted QA workflows.
Copy the .claude folder to your project:
cp -r cdp-qa-toolkit/.claude your-project/.claude| Persona | Invoke With | Purpose |
|---|---|---|
| QA Tester | "Hey QA Claude..." | Browser automation, screenshots, verification |
| Orchestrator | "Orchestrator mode" | Task breakdown, persona coordination |
User: Hey QA Claude, verify the login form works
Claude: I'll verify the login form using CDP.
1. First, let me check the connection:
[Runs: npm run qa status]
2. Taking a screenshot of the login page:
[Runs: npm run qa screenshot desktop]
3. Testing form interaction:
[Runs: npm run qa type "input[name='email']" "test@example.com"]
[Runs: npm run qa screenshot desktop]
## QA Verification Report
**Test:** Login form functionality
**Result:** PASS
### Evidence
- Screenshot: `qa-screenshots/login_desktop_1707123456.png`
- Form accepts input correctly
- Submit button is visible and clickable
The personas enforce a critical rule: All code changes must be verified in the browser before marking complete.
TypeScript compiling ≠ working code. Build passing ≠ correct UI. Only visual verification counts.
const {
waitFor,
clickElement,
typeInto,
takeScreenshot,
cdp,
getLocalhost
} = require('./qa/cdp-qa.js');
async function testLogin() {
const page = await getLocalhost();
const { send, close } = await cdp(page.webSocketDebuggerUrl);
try {
await typeInto(send, 'input[name="email"]', 'test@example.com');
await typeInto(send, 'input[name="password"]', 'password123');
await clickElement(send, 'button[type="submit"]');
await waitFor(send, '[data-testid="dashboard"]', { timeout: 5000 });
console.log('Login successful!');
} finally {
close();
}
}| CDP QA | Playwright | |
|---|---|---|
| Dependencies | 1 (ws) | 100+ |
| Install size | ~100KB | ~100MB |
| Startup time | Instant | 2-5 seconds |
| Use case | Quick visual checks | Full E2E suites |
Use CDP for rapid development verification. Use Playwright for comprehensive test suites and CI.
cdp-qa-toolkit/
├── qa/
│ └── cdp-qa.js # Main CLI tool
├── .claude/
│ ├── personas/
│ │ ├── qa-tester.md # QA automation persona
│ │ └── orchestrator.md # Task coordination persona
│ └── LESSONS-LEARNED.md # Common issues and solutions
├── qa.config.example.js # Configuration template
├── package.json
└── README.md
MIT