Metadata-Version: 2.4
Name: chromedeveloperprotocol-client
Version: 0.2.1
Summary: Python wrapper for Chrome DevTools Protocol
Requires-Python: >=3.13
Requires-Dist: httpx>=0.28.1
Requires-Dist: inflection>=0.5.1
Requires-Dist: ipykernel>=7.1.0
Requires-Dist: jinja2-strcase>=0.0.2
Requires-Dist: jinja2>=3.1.6
Requires-Dist: websockets>=15.0.1
Provides-Extra: test
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'test'
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
Requires-Dist: pytest>=8.0.0; extra == 'test'
Description-Content-Type: text/markdown

# CDP Client

Python wrapper for Chrome DevTools Protocol.

## Installation

```bash
pip install chromedeveloperprotocol-client
```

## Usage

This example shows how to connect to a running browser and fetch its version information.

### Hello World Example

```python
import asyncio
import httpx
from cdp import Client

async def get_ws_url(port=9222):
    async with httpx.AsyncClient() as http:
        resp = await http.get(f"http://localhost:{port}/json/version")
        return resp.json()['webSocketDebuggerUrl']

async def main():
    # Connect to an existing browser session
    # Browser must be started with --remote-debugging-port=9222
    ws_url = await get_ws_url()
    
    async with Client(ws_url) as client:
        # Fetch browser version information
        version = await client.browser.get_version({})
        print(f"Browser: {version['product']}")
        
        # Create a new page and navigate
        target = await client.target.create_target({"url": "https://www.google.com"})
        print(f"Created target: {target['targetId']}")

if __name__ == "__main__":
    asyncio.run(main())
```

## Running the Examples

Ensure you have a browser (Chrome or Edge) running with remote debugging enabled:

```bash
chrome.exe --remote-debugging-port=9222
```

## Updating the CDP Protocols

The library automatically generates its protocol definitions from the upstream [ChromeDevTools/devtools-protocol](https://github.com/ChromeDevTools/devtools-protocol) repository during build/installation. 

To fetch the latest protocol definitions and update the client code, run:

```bash
uv sync --reinstall-package chromedeveloperprotocol-client
```
This will trigger the build hook which pulls the latest JSON files and regenerates the `src/cdp` directory.

