Skip to main content

Chrome

Manages a headless Chrome browser process.

Usage

Source

Chrome(
    path=None,
    headless=True,
    extra_args=None,
    timeout=20.0,
    transport=None,
)

Launches Chrome with remote debugging enabled over WebSocket or pipes.

Parameters

path: str | None = None

Path to Chrome executable. If None, auto-detected via find_chrome().

headless: bool = True

Whether to run in headless mode.

extra_args: list[str] | None = None

Additional command-line arguments to pass to Chrome. These come after any arguments in the NOKAP_CHROME_ARGS environment variable.

timeout: float = 20.0

Maximum seconds to wait for Chrome’s DevTools endpoint to become ready.

transport: str | None = None
“websocket” or “pipe”. Defaults to NOKAP_TRANSPORT when set, otherwise “pipe” on macOS/Linux and “websocket” on Windows. Pipe transport requires POSIX. Select “websocket” to use ws_url or port.

Notes

On macOS, nokap selects --single-process when the user-directory queries needed for Chrome’s child sandboxes fail with EIO. If Chrome instead reports a Mach registration denial, nokap retries once with --single-process.

Attributes

Name Description
pid The Chrome process ID, or None if not running.
pipes The read and write descriptors for pipe-mode DevTools communication.
port The remote debugging port.
stderr Chrome’s startup diagnostics when using pipe transport.
transport The selected DevTools transport.
ws_url The WebSocket URL for CDP communication.

Functions

Name Description
close() Shut down Chrome before removing its temporary profile.
is_alive() Check if the Chrome process is still running.