Registry / devops / cdp-patches

cdp-patches

JSON →
library1.1pypypi✓ verified 86d ago

CDP-Patches is a Python library designed for patching Chrome DevTools Protocol (CDP) leaks at the operating system level. It aimed to address issues like input domain leaks and the inability of CDP to dispatch coalesced events, making web automation with tools like Playwright and Selenium more robust against bot detection. Version 1.1, released on September 28, 2025, represents its latest and likely final iteration.

pip install cdp-patches
INSTALL
IMPORT
SIG · CDP-PATCHES
C
cdp-patches
devopspythonv1.1
Install
22.0s avg
Import
Disk
96MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 4.61s
py 3.11
4/8 runs
7/8 runs
py 3.12
4/8 runs
✓ 55.96s
py 3.13
4/8 runs
4/8 runs
py 3.9
✓ —
✓ 5.4s
96MB installed
● package 96MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SyncInput
from cdp_patches.input import SyncInput
AsyncInput
from cdp_patches.input import AsyncInput

This quickstart demonstrates how to use `cdp-patches` with Selenium to perform an OS-level click on a web element. It highlights the use of `SyncInput` to interact with a headful Chrome browser instance. This approach bypasses standard CDP input commands, which might be detected as automation, by dispatching events at the operating system level.

import os from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement from cdp_patches.input import SyncInput # NOTE: This example requires a ChromeDriver executable in your PATH # and a headful Chrome browser to run, as cdp-patches works on OS-level events. def get_locator_pos(locator: WebElement): location = locator.location size = locator.size assert location and size x, y, width, height = location.get("x"), location.get("y"), size.get("width"), size.get("height") assert x is not None and y is not None and width is not None and height is not None # Calculate center of the element x, y = x + width // 2, y + height // 2 return x, y options = webdriver.ChromeOptions() # Disable logs & automation flags for stealth (recommended for general automation, not specific to cdp-patches) options.add_experimental_option("excludeSwitches", ["enable-logging", "enable-automation"]) options.add_experimental_option("useAutomationExtension", False) options.add_argument("--log-level=3") # Ensure Chrome is launched headfully # For local testing, ensure ChromeDriver is in PATH or specify service.executable_path try: with webdriver.Chrome(options=options) as driver: # cdp-patches operates on the browser's process ID (PID) or WebDriver instance sync_input = SyncInput(browser=driver) driver.get("https://www.google.com") # Example: Find a search bar and click it using OS-level input search_bar = driver.find_element(By.NAME, "q") x, y = get_locator_pos(search_bar) print(f"Clicking search bar at: ({x}, {y})") sync_input.click("left", x, y) print("Successfully clicked element using CDP-Patches SyncInput.") except Exception as e: print(f"An error occurred: {e}") print("Please ensure Chrome browser and ChromeDriver are installed and configured correctly.") print("Also, remember cdp-patches requires a headful browser.")
Debug
Known issues
breakingThe primary 'Input Leak' (crbug#1477537) that this library aimed to fix has been resolved in Chrome-Stable v142+. CoalescedEvents are now also emitted by input events, rendering the main purpose of this package obsolete for modern Chrome versions.
fix
Update your Chrome browser to v142 or newer. The library is largely unneeded, except for a specific 'Select Elements' bug (crbug#40943840).
affects: Chrome v142+
deprecatedThe official GitHub repository for cdp-patches has been archived by the owner, making it read-only. This indicates that the project is no longer actively maintained.
fix
Consider migrating to alternative solutions or relying on the native fixes in modern Chrome versions. This package is unlikely to receive further updates or bug fixes.
affects: All versions
gotchaDue to its reliance on OS-level events, `cdp-patches` can only be used with headful browsers. It will not function correctly with headless browser environments.
fix
Ensure your browser automation setup explicitly launches Chrome in headful mode (e.g., `headless=False` in Playwright or `options.add_argument('--headless=new')` is not used in Selenium if you intend to use cdp-patches).
affects: All versions
gotchaThe OS-level input methods implemented by `cdp-patches` are sensitive to system-level key presses. Manually pressing keys like SHIFT or CAPSLOCK on Windows can interfere with automated input.type(text) operations.
fix
Avoid manual keyboard interaction with the system while `cdp-patches` is actively dispatching input events. Isolate the automation environment if possible.
affects: All versions
gotchaChrome does not recognize Input Events to specific tabs when dispatched at the OS level. Therefore, `cdp-patches` methods can only reliably be used on the currently active tab.
fix
Ensure that the target tab is the active, focused tab when using `cdp-patches` for input automation.
affects: All versions
Errors
Common errors & fixes
CDP-Patches is not fixing my input leaks anymore / My bot is still detected despite using cdp-patches.
The underlying Chrome bug (crbug#1477537) that caused the input leak has been fixed in Chrome v142+. Your detection might be due to other factors, or the package's primary utility is no longer relevant for modern browsers.
fix
Update your Chrome browser to v142+ to benefit from native fixes. Review other aspects of your automation setup for bot detection vectors, as this library's core function is largely obsolete.
ModuleNotFoundError: No module named 'cdp_patches.input' OR Cannot import SyncInput/AsyncInput
The `cdp-patches` library is either not installed or you are using an incorrect import path.
fix
Ensure the library is installed: `pip install cdp-patches`. Use the correct import statement: `from cdp_patches.input import SyncInput` or `from cdp_patches.input import AsyncInput`.
AttributeError: 'WebDriver' object has no attribute 'get_pid' OR SyncInput(pid=None) error
`SyncInput` or `AsyncInput` was initialized without a valid browser `pid` or `browser` instance, or the `browser` object passed does not expose a `pid` compatible with the library's expectations, especially in older versions or non-standard setups.
fix
When initializing `SyncInput`, ensure you pass a valid `browser` object from Playwright/Selenium that `cdp-patches` can extract a PID from, or explicitly provide the browser's process ID: `sync_input = SyncInput(browser=driver)` (for Selenium) or `sync_input = SyncInput(pid=your_browser_pid)`.
Upgrade
Version history
1.1latest on PyPI · released Sep 28, 2025
Audit
Dependencies
pythonrequiredRequires Python 3.8 or higher.
seleniumoptionalRequired for the provided quickstart examples and common usage patterns.
playwrightoptionalIncluded in the 'automation_linting' extra for comprehensive web automation.
botrightoptionalIncluded in the 'automation_linting' extra for comprehensive web automation.
selenium_driverlessoptionalIncluded in the 'automation_linting' extra for comprehensive web automation.
Agent activity
22 hits · last 30 days
node
20
Bingbot
1
OpenAI (training)
1
Resources
cdp-patches — pip install cdp-patches · libregistry