Python library for interacting with the chrome devtools protocol
Project description
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:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python_cdp-0.3.0.tar.gz
.
File metadata
- Download URL: python_cdp-0.3.0.tar.gz
- Upload date:
- Size: 107.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce1a29086a3b41e596b40386f760afc009f54c870eddac624bb1de833ac343fa |
|
MD5 | 5d49feaa23491382aaaf407b887b3a99 |
|
BLAKE2b-256 | 010f38f82a40c9e6f231b4c353015ffda25b91873f92aba7bbde6bf20e5bf544 |
File details
Details for the file python_cdp-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: python_cdp-0.3.0-py3-none-any.whl
- Upload date:
- Size: 146.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.2 Linux/5.15.0-1034-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65a280817ba71c36b076359290a1e2cd9f3588cfc59e3b4f75e3cd2d1558eac4 |
|
MD5 | fb8464eb2b1bb929fe6b398eae291b70 |
|
BLAKE2b-256 | 6f72bf914a11756138ec758b24bf48abdae2918c9919ba04d0f2ea4d7a8b84b2 |