NOTE: Tests are currently broken due to an upstream Chromium bug: https://bugs.chromium.org/p/chromium/issues/detail?id=849972
Process lifecycle management, tab management, plus the complete chrome remote debugging interface is exposed through to python.
Automatically updates via automatic code generation by parsing the remote debugging protocol descripion json files.
This library makes extensive use of the python
logging framework, and logs to
Main.ChromeController.* log path.
Automatic wrapper class creation for the remote interface by parsing
protocol.json file, and dynamic code generation through dynamic
AST building. While this is not the most maintainable design, I chose it mostly
because I wanted an excuse to learn/experiment with python AST manipulation.
A higher level automation layer is implemented on top of the autogenerated wrapper. Both the higher-level interface, and it's associated documentation are very much a work in process at the moment.
Interface documentation is here:
All remote methods are wrapped in named functions, with (partial) validation of passed parameter types and return types. Right now, simple parameter type validation is done (e.g. text arguments must be of type string, numeric arguments must be either an int or a float, etc..). However, the compound type arguments (bascally, anything that takes an array or object) are not validated, due to the complexity of properly constructing type validators for their semantics given the architecture (read: writing the validator in raw AST broke my brain).
Tested mostly on python 3.5, 3.6, lightly on 3.8 and 3.7, all on linux. If you are
using python 2, please stahp. It works with normal chromium and on windows,
but that has only been very lightly used. My test-target is the
Note that this tool generates and manipulates the AST directly, so it is EXTREMELY sensitive to implementation details. It is probably broken on python > 3.8 or < 3.5.
Transport layer (originally) from https://github.com/minektur/chrome_remote_shell
The library also has a relatively useful CLI interface, principally useful for doing things like fetching pages which have jerberscript-rendered content:
python3 -m ChromeController --help Usage: __main__.py [OPTIONS] COMMAND [ARGS]... ChromeController Usage: python3 -m ChromeController [-s | --silent] [-v | --verbose] python3 -m ChromeController fetch <url> [--binary <bin_name>] [--outfile <out_file_name>] python3 -m ChromeController update python3 -m ChromeController (-h | --help) python3 -m ChromeController --version Options: -s --silent Suppress all output aside from the fetched content This basically makes ChromeController act like a alternative to curl -v --verbose The opposite of silent. Causes the internal logging to output all traffic over the chromium control interface. VERY noisy. --version Show version. fetch Fetch a specified URL's content, and output it to the console. Options: -v, --verbose The opposite of silent. Causes the internal logging to output all traffic over the chromium control interface. VERY noisy. -s, --silent Suppress all output aside from the fetched content. This can be used to make ChromeController act like an alternative to curl with proper JS rendering. --help Show this message and exit. Commands: fetch Fetch a specified URL's content, and output... update Update the generated class version Print the ChromeController Version
Current Usage so far has been basically to find bugs or strangeness in the chromium remote debug interface:
network.clearBrowserCookiesappears to have no effect (fixed)