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
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.")
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.
fixUpdate 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.
fixEnsure 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.
fixWhen 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.