--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: Concurrent Sessions Can Share Selenium’s CDP Connection
Each WebDriver session drives a page of its own, with its own cookies and storage. Selenium’s CDP connection, which Nightwatch’s captureNetworkRequests and setGeolocation use, drives the first page /json/list names, the most recently active, so with sessions running at once it can reach another session’s page.
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 the process.
Example
Serve on port 9222:
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()zshot --cdp --cdp-webdriver -- python capture.py