{"id":8003,"library":"cdp-patches","title":"CDP-Patches","description":"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.","status":"deprecated","version":"1.1","language":"en","source_language":"en","source_url":"https://github.com/Kaliiiiiiiiii-Vinyzu/CDP-Patches/","tags":["playwright","selenium","web automation","chrome devtools protocol","cdp","patch","bot detection","fingerprinting","undetectable"],"install":[{"cmd":"pip install cdp-patches","lang":"bash","label":"Basic Installation"},{"cmd":"pip install cdp-patches[automation_linting]","lang":"bash","label":"Installation with Automation Linting (includes playwright, botright, selenium, selenium_driverless)"}],"dependencies":[{"reason":"Requires Python 3.8 or higher.","package":"python","optional":false},{"reason":"Required for the provided quickstart examples and common usage patterns.","package":"selenium","optional":true},{"reason":"Included in the 'automation_linting' extra for comprehensive web automation.","package":"playwright","optional":true},{"reason":"Included in the 'automation_linting' extra for comprehensive web automation.","package":"botright","optional":true},{"reason":"Included in the 'automation_linting' extra for comprehensive web automation.","package":"selenium_driverless","optional":true}],"imports":[{"symbol":"SyncInput","correct":"from cdp_patches.input import SyncInput"},{"symbol":"AsyncInput","correct":"from cdp_patches.input import AsyncInput"}],"quickstart":{"code":"import os\nfrom selenium import webdriver\nfrom selenium.webdriver.common.by import By\nfrom selenium.webdriver.remote.webelement import WebElement\nfrom cdp_patches.input import SyncInput\n\n# NOTE: This example requires a ChromeDriver executable in your PATH\n# and a headful Chrome browser to run, as cdp-patches works on OS-level events.\n\ndef get_locator_pos(locator: WebElement):\n    location = locator.location\n    size = locator.size\n    assert location and size\n    x, y, width, height = location.get(\"x\"), location.get(\"y\"), size.get(\"width\"), size.get(\"height\")\n    assert x is not None and y is not None and width is not None and height is not None\n    # Calculate center of the element\n    x, y = x + width // 2, y + height // 2\n    return x, y\n\noptions = webdriver.ChromeOptions()\n# Disable logs & automation flags for stealth (recommended for general automation, not specific to cdp-patches)\noptions.add_experimental_option(\"excludeSwitches\", [\"enable-logging\", \"enable-automation\"])\noptions.add_experimental_option(\"useAutomationExtension\", False)\noptions.add_argument(\"--log-level=3\")\n\n# Ensure Chrome is launched headfully\n# For local testing, ensure ChromeDriver is in PATH or specify service.executable_path\n\ntry:\n    with webdriver.Chrome(options=options) as driver:\n        # cdp-patches operates on the browser's process ID (PID) or WebDriver instance\n        sync_input = SyncInput(browser=driver)\n\n        driver.get(\"https://www.google.com\")\n\n        # Example: Find a search bar and click it using OS-level input\n        search_bar = driver.find_element(By.NAME, \"q\")\n        x, y = get_locator_pos(search_bar)\n        print(f\"Clicking search bar at: ({x}, {y})\")\n        sync_input.click(\"left\", x, y)\n        print(\"Successfully clicked element using CDP-Patches SyncInput.\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n    print(\"Please ensure Chrome browser and ChromeDriver are installed and configured correctly.\")\n    print(\"Also, remember cdp-patches requires a headful browser.\")\n","lang":"python","description":"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."},"warnings":[{"fix":"Update your Chrome browser to v142 or newer. The library is largely unneeded, except for a specific 'Select Elements' bug (crbug#40943840).","message":"The 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.","severity":"breaking","affected_versions":"Chrome v142+"},{"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.","message":"The 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.","severity":"deprecated","affected_versions":"All versions"},{"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).","message":"Due 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Avoid manual keyboard interaction with the system while `cdp-patches` is actively dispatching input events. Isolate the automation environment if possible.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure that the target tab is the active, focused tab when using `cdp-patches` for input automation.","message":"Chrome 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"CDP-Patches is not fixing my input leaks anymore / My bot is still detected despite using cdp-patches."},{"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`.","cause":"The `cdp-patches` library is either not installed or you are using an incorrect import path.","error":"ModuleNotFoundError: No module named 'cdp_patches.input' OR Cannot import SyncInput/AsyncInput"},{"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)`.","cause":"`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.","error":"AttributeError: 'WebDriver' object has no attribute 'get_pid' OR SyncInput(pid=None) error"}]}