# Chrome

Manages a headless Chrome browser process.

Usage

[Source](https://github.com/posit-dev/nokap/blob/main/nokap/_browser.py#L171-L356)

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

Launches Chrome with remote debugging enabled and provides the WebSocket URL for CDP communication.

## Parameters

`path: str | None = None`  
Path to Chrome executable. If None, auto-detected via [find_chrome()](../reference/find_chrome.md#nokap.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 to start and report its WS URL.

## Notes

If Chrome fails because a macOS sandbox denies it mach-register (as Seatbelt-based agent sandboxes do), nokap retries once with `--single-process`.

## Attributes

| Name              | Description                                    |
|-------------------|------------------------------------------------|
| [pid](#pid)       | The Chrome process ID, or None if not running. |
| [port](#port)     | The remote debugging port.                     |
| [ws_url](#ws_url) | The WebSocket URL for CDP communication.       |

### pid

The Chrome process ID, or None if not running.

`pid: int | None`

### port

The remote debugging port.

`port: int`

### ws_url

The WebSocket URL for CDP communication.

`ws_url: str`

## Methods

| Name                    | Description                                   |
|-------------------------|-----------------------------------------------|
| [close()](#close)       | Terminate the Chrome process.                 |
| [is_alive()](#is_alive) | Check if the Chrome process is still running. |

### close()

Terminate the Chrome process.

Usage

[Source](https://github.com/posit-dev/nokap/blob/main/nokap/_browser.py#L328-L346)

``` python
close()
```

### is_alive()

Check if the Chrome process is still running.

Usage

[Source](https://github.com/posit-dev/nokap/blob/main/nokap/_browser.py#L322-L326)

``` python
is_alive()
```
