Skip to main content

version supports test coverage docs

python-cdp (ALPHA)


python-cdp is a python library that can be used to attach to a remotely running chrome instance for debugging. In order to connect to the browser it should be launched with --remote-debugging-port=X. python-cdp exposes a simple client for asyncio and various wrappers for the devtools protocol. This is all event driven and bidirectional via websockets.

The protocol itself at the tip of tree is moving fast, this library aims to support all domains that are not currently deprecated.


Low Level Details

Chrome devtools protocol is built on the concept of Domains. These domains typically expose an API in the form of:

* Commands
* Types
* Events

Each Domain advertised by the CDP will have its own module file written in python_cdp/cdp/{domain}.py and have fully type hinted classes for (de)serialisation.


Goals for Future

python-cdp aims to implement a typed API for the protocol (and maintain) that fully going forward. Eventually it hopes to expose a websocket connection/API for actually interacting with the protocol but that is a way off yet.

  • Full marshalling capabilities for all non deprecated domains.
  • An asyncio client for interacting and connecting to chrome in debug mode.
  • Useful utilities for making interactions that little bit easier.
  • 100% type hinted code base
  • Completely auto generated client to make changes and releases as pain free as possible.
  • Auto detection of upstream protocol rollups and auto releases triggered.

Contributing

This project takes the devtools protocol json files and based on those generates python source code. It is not currently building AST trees to unparse but it may do so in future, for now it is generating relatively complex source code (largely in the form of python dataclasses). In order to generate the files again do the following:

poetry shell
poetry install
python -m python_cdp.generate
tox -e linting  # format the generated source code (will unstage)
# inspect the `python_cdp/cdp/*` directory.

The CDP protocol repository is a submodule within this repository and will be automatically updated when google releases changes on the upstream repository.

The power of keeping the repository auto generated is that it requires minimmal maintenance work when the tip-of-the-tree for the protocol is updated which is pretty much every day, the target is forever moving.


Useful utilities

The below examples use the power jq tool to generate output that can be useful for debugging or checking things that should be generated etc.

Generating all the possible properties that an Event class may need:

Metadata

Release files for python-cdp 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-cdp 0.3.0
File Size Uploaded
python_cdp-0.3.0.tar.gz 107.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-cdp 0.3.0
File Interpreter ABI Platform
python_cdp-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 254.0 kB

Release files / python_cdp-0.3.0.tar.gz

Download URL python_cdp-0.3.0.tar.gz
Size 107.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ce1a29086a3b41e596b40386f760afc009f54c870eddac624bb1de833ac343fa
BLAKE2b-256 checksum
How to use checksums
010f38f82a40c9e6f231b4c353015ffda25b91873f92aba7bbde6bf20e5bf544
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1034-azure

Release files / python_cdp-0.3.0-py3-none-any.whl

Download URL python_cdp-0.3.0-py3-none-any.whl
Size 146.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65a280817ba71c36b076359290a1e2cd9f3588cfc59e3b4f75e3cd2d1558eac4
BLAKE2b-256 checksum
How to use checksums
6f72bf914a11756138ec758b24bf48abdae2918c9919ba04d0f2ea4d7a8b84b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1034-azure

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page