Chrome DevTools Protocol automation toolkit — zero-dependency, ~15KB vs 300MB Playwright
Project description
CDP Toolkit
Chrome DevTools Protocol automation without external dependencies. No Playwright, no Selenium, no Puppeteer. Pure Python stdlib.
Install
pip install cdp-toolkit
Why CDP Toolkit?
| Feature | Playwright | Selenium | cdp-toolkit |
|---|---|---|---|
| Dependencies | 50+ packages | 20+ packages | 0 |
| Install size | ~300MB | ~150MB | ~15KB |
| Browser download | Yes (~200MB) | Yes (~100MB) | No |
| Learning curve | Medium | High | Low |
| Speed | Fast | Slow | Fastest |
| Cloud-native | Yes | Partial | Yes |
CDP Toolkit talks directly to Chrome's DevTools Protocol via HTTP and WebSocket. You bring your own Chrome instance (local, Docker, or cloud), and CDP Toolkit handles the rest.
Quick Start
from cdp_toolkit import CDPClient
# Connect to a Chrome instance with --remote-debugging-port=9222
client = CDPClient("127.0.0.1", 9222)
# List open tabs
tabs = client.list_targets()
for tab in tabs:
print(f"{tab['id'][:8]} | {tab['url'][:60]}")
# Create a new tab
new_tab = client.create_target("https://example.com")
# Navigate
client.navigate(new_tab['id'], "https://httpbin.org/forms/post")
# Execute JavaScript
title = client.evaluate(new_tab['id'], "document.title")
print(f"Page title: {title}")
React/Vue Form Filling
The most common CDP use case: filling forms on React/Vue/Angular sites where standard input.value = "x" does not trigger reactivity.
from cdp_toolkit import CDPInput
# Generate native setter JavaScript for React
js_code = CDPInput.native_setter_js(
selector="#email",
value="user@example.com"
)
# Execute via CDP — triggers React's onChange handler
# For Vue.js
js_code = CDPInput.vue_setter_js(
selector="input[name='phone']",
value="+1234567890"
)
# Key-by-key typing simulation
js_code = CDPInput.simulate_typing(
selector="#search",
text="hello world",
delay_ms=50
)
Mouse Events
from cdp_toolkit import CDPMouseEvents
# Click at coordinates
params = CDPMouseEvents.click(x=200, y=300)
# Right-click
params = CDPMouseEvents.click(x=200, y=300, button="right")
# Double-click
params = CDPMouseEvents.double_click(x=200, y=300)
# Drag and drop
params = CDPMouseEvents.drag(
start_x=100, start_y=200,
end_x=400, end_y=300
)
Navigation and Screenshots
from cdp_toolkit import CDPNavigation
# Navigate and wait for load
client.navigate_and_wait(tab_id, "https://example.com")
# Take screenshot
screenshot_b64 = client.screenshot(tab_id)
# Scroll to element
js = CDPNavigation.scroll_to_element("#footer")
client.evaluate(tab_id, js)
# Wait for selector
js = CDPNavigation.wait_for_selector(".result-card", timeout_ms=5000)
Anti-Detection
CDP Toolkit includes JavaScript snippets to make automation less detectable:
from cdp_toolkit import stealth
# Remove webdriver flag
client.evaluate(tab_id, stealth.remove_webdriver_flag())
# Override navigator properties
client.evaluate(tab_id, stealth.override_navigator())
# Add realistic timing jitter
CDPInput.set_typing_delay(min_ms=30, max_ms=120)
Docker Integration
Run Chrome in Docker and control it with CDP Toolkit:
# Dockerfile
FROM chrome/headless
EXPOSE 9222
CMD ["chrome", "--remote-debugging-port=9222", "--no-sandbox"]
# Connect to Docker Chrome
client = CDPClient("chrome-container", 9222)
Testing
python -m pytest tests/ -v --tb=short
38 tests covering all modules. Zero external dependencies in tests.
API Reference
CDPClient
| Method | Description |
|---|---|
list_targets() |
List all open tabs/pages |
create_target(url) |
Open a new tab |
close_target(id) |
Close a tab |
activate_target(id) |
Focus a tab |
navigate(id, url) |
Navigate to URL |
evaluate(id, js) |
Execute JavaScript |
screenshot(id) |
Capture page screenshot |
CDPInput
| Method | Description |
|---|---|
native_setter_js(sel, val) |
React-compatible value setter |
vue_setter_js(sel, val) |
Vue.js-compatible value setter |
simulate_typing(sel, text, delay) |
Human-like typing simulation |
key_event(key) |
Send keyboard event |
CDPMouseEvents
| Method | Description |
|---|---|
click(x, y, button) |
Mouse click |
double_click(x, y) |
Double click |
drag(sx, sy, ex, ey) |
Drag and drop |
hover(x, y) |
Mouse hover |
License
MIT — see LICENSE
Links
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cdp_toolkit-1.4.0.tar.gz.
File metadata
- Download URL: cdp_toolkit-1.4.0.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
145b02d6379eed755d43f3c58ae955e5e904c02628767e058d9e3571429649a1
|
|
| MD5 |
ccfb8b1f514c71e78016f17ffd2cfc03
|
|
| BLAKE2b-256 |
34fe6391a02d2398922a734201f7f6e65ff5ac5f9151094e15de3a7217ec18d0
|
Provenance
The following attestation bundles were made for cdp_toolkit-1.4.0.tar.gz:
Publisher:
publish.yml on AMEOBIUS-team/cdp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdp_toolkit-1.4.0.tar.gz -
Subject digest:
145b02d6379eed755d43f3c58ae955e5e904c02628767e058d9e3571429649a1 - Sigstore transparency entry: 2147905532
- Sigstore integration time:
-
Permalink:
AMEOBIUS-team/cdp-toolkit@a7953e5b0fb0abd66a1336db57dab413d919365d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AMEOBIUS-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7953e5b0fb0abd66a1336db57dab413d919365d -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file cdp_toolkit-1.4.0-py3-none-any.whl.
File metadata
- Download URL: cdp_toolkit-1.4.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
356be5acc993f55ad7d9b6771fcaf15fb969bc2aea124c0d4fdabbb556a5f363
|
|
| MD5 |
593029da3d01376f6579d39346032dfd
|
|
| BLAKE2b-256 |
af5dd403e4e2f52eac76d1ea8b400a05d2409d4994a8e247d12f5086ba6287ee
|
Provenance
The following attestation bundles were made for cdp_toolkit-1.4.0-py3-none-any.whl:
Publisher:
publish.yml on AMEOBIUS-team/cdp-toolkit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cdp_toolkit-1.4.0-py3-none-any.whl -
Subject digest:
356be5acc993f55ad7d9b6771fcaf15fb969bc2aea124c0d4fdabbb556a5f363 - Sigstore transparency entry: 2147905575
- Sigstore integration time:
-
Permalink:
AMEOBIUS-team/cdp-toolkit@a7953e5b0fb0abd66a1336db57dab413d919365d -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AMEOBIUS-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7953e5b0fb0abd66a1336db57dab413d919365d -
Trigger Event:
workflow_dispatch
-
Statement type: