<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Headless Browser Templates — API Reference

## Nuclei Headless Execution

```bash
# Run headless template
nuclei -u https://target.com -t headless-template.yaml -headless -json

# With custom page timeout
nuclei -u https://target.com -t template.yaml -headless -page-timeout 30

# Show browser (non-headless for debugging)
nuclei -u https://target.com -t template.yaml -headless -show-browser

# With system Chrome
nuclei -u https://target.com -t template.yaml -headless -system-chrome
```

## Headless Action Types

| Action | Description | Required Args |
|--------|-------------|---------------|
| `navigate` | Browse to a URL | `url` |
| `waitload` | Wait for page load complete | — |
| `click` | Click an element | `by`, `xpath` or `selector` |
| `text` | Type into an input | `by`, `xpath`/`selector`, `value` |
| `script` | Execute JavaScript | `code`, `name` (for output) |
| `screenshot` | Take page screenshot | — |
| `sleep` | Wait for duration | `duration` (ms) |
| `keyboard` | Send keyboard event | `keys` |
| `waitvisible` | Wait for element visible | `by`, `xpath`/`selector` |
| `debug` | Print debug info | — |
| `setmethod` | Set HTTP method | `part` (request), `method` |
| `addheader` | Add HTTP header | `part`, `key`, `value` |
| `deleteheader` | Remove HTTP header | `part`, `key` |
| `getresource` | Get loaded resource | `url` |
| `extract` | Extract from element | `by`, `xpath`/`selector`, `name` |
| `waitdialog` | Wait for JS dialog | `timeout` |

## Element Selectors

| By | Syntax | Example |
|----|--------|---------|
| `x` | XPath expression | `//input[@name='q']` |
| `css` | CSS selector | `input.search-box` |
| `id` | Element ID | `searchInput` |
| `name` | Element name | `q` |

## Script Action Output

```yaml
# Script must return a value to be used in matchers
- action: script
  args:
    code: |
      () => {
        return document.title;
      }
    name: page_title  # referenced as part: page_title in matchers
```

## Headless CLI Flags

| Flag | Description |
|------|-------------|
| `-headless` | Enable headless browser mode |
| `-page-timeout` | Page load timeout in seconds |
| `-show-browser` | Show browser window (debug) |
| `-system-chrome` | Use system Chrome instead of bundled |
| `-headless-options` | Additional Chrome arguments |
| `-headless-no-sandbox` | Disable Chrome sandbox |
