--cdp-webdriver
- CLI
- --cdp-webdriver
- REST
- CLI only
Serves chromedriver’s attach beside the --cdp endpoint, so a WebDriver client drives the browser through goog:chromeOptions.debuggerAddress. Requires --cdp.
| Addition | Value |
|---|---|
GET /, /, / | Chromium’s discovery documents, naming the relay’s endpoints |
/ | A socket per page |
ZSHOT_ | HOST:PORT for the debugger address, set for a --cdp -- COMMAND |
Use a chromedriver of the same major version as ZShot’s Chromium, which /json/version reports as Browser; another version refuses the session.
Warning: Window Resizing Is Poorly Supported
ZShot answers WebDriver’s window calls itself, since its browser has no window. Setting the window resizes the page’s layout, but a screenshot keeps the browser’s starting size, and the window and screen the page reads stay at their first values.
Warning: The Attach Carries No Token
Any local process can drive the browser while ZShot runs. --cdp must bind a loopback address; another address exits with code 3.
Example
Serve on port 9222:
CLI
Run locally
zshot --cdp 127.0.0.1:9222 --cdp-webdriverRun a Selenium script against ZShot, with capture.py:
import os
from selenium import webdriver
options = webdriver.ChromeOptions()
options.debugger_address = os.environ["ZSHOT_DEBUGGER_ADDRESS"]
driver = webdriver.Chrome(options=options)
driver.get("https://zshot-cli.com/example_assets/hello_zshot/")
driver.save_screenshot("hello.png")
print(driver.title)
driver.quit()CLI
Run locally
zshot --cdp --cdp-webdriver -- python capture.py