> ## Documentation Index
> Fetch the complete documentation index at: https://piyushvyas.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Methods

> Complete reference for all 55 BAP protocol methods organized by category.

BAP defines 55 methods across 13 categories. All methods use JSON-RPC 2.0 request/response format over WebSocket.

## Lifecycle (3)

| Method                      | Description                                                                                    |
| --------------------------- | ---------------------------------------------------------------------------------------------- |
| `initialize`                | Handshake -- returns server capabilities. Accepts optional `sessionId` for session persistence |
| `notifications/initialized` | Client confirms ready (notification, no response)                                              |
| `shutdown`                  | Clean shutdown of the connection                                                               |

## Browser (2)

| Method           | Description             |
| ---------------- | ----------------------- |
| `browser/launch` | Launch browser instance |
| `browser/close`  | Close browser instance  |

<Accordion title="browser/launch parameters">
  \| Parameter | Type | Default | Description | |-----------|------|---------|-------------| |
  `browser` | `"chromium" \| "firefox" \| "webkit"` | `"chromium"` | Browser engine | | `channel` |
  `string` | -- | Playwright channel (e.g., `"chrome"`, `"msedge"`) | | `headless` | `boolean` |
  `true` | Run in headless mode | | `args` | `string[]` | -- | Additional browser arguments | |
  `proxy` | `object` | -- | Proxy configuration | | `downloadsPath` | `string` | -- | Directory for
  downloads | | `userDataDir` | `string` | -- | Persistent user data directory | | `cdpUrl` |
  `string` | -- | Connect to existing browser via CDP |
</Accordion>

## Page (8)

| Method           | Description                                                          |
| ---------------- | -------------------------------------------------------------------- |
| `page/create`    | Create new page. Params: `url`, `viewport`, `userAgent`, `contextId` |
| `page/navigate`  | Navigate to URL. Supports `observe` fusion param                     |
| `page/reload`    | Reload current page                                                  |
| `page/goBack`    | Navigate back in history                                             |
| `page/goForward` | Navigate forward in history                                          |
| `page/close`     | Close page                                                           |
| `page/list`      | List all open pages                                                  |
| `page/activate`  | Bring page to front                                                  |

<Accordion title="page/navigate parameters">
  \| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | `url`
  \| `string` | -- | Target URL (required) | | `waitUntil` | `"load" \| "domcontentloaded" \|
      "networkidle"` | `"load"` | When to consider navigation complete | | `timeout` | `number` | 30000
  \| Navigation timeout in ms | | `observe` | `AgentObserveParams` | -- | Fused observation after
  navigation |
</Accordion>

## Actions (13)

| Method            | Description                                    |
| ----------------- | ---------------------------------------------- |
| `action/click`    | Click element                                  |
| `action/dblclick` | Double-click element                           |
| `action/type`     | Type text character by character               |
| `action/fill`     | Fill input field (clears existing value first) |
| `action/clear`    | Clear input field                              |
| `action/press`    | Press keyboard key (e.g., `"Enter"`, `"Tab"`)  |
| `action/hover`    | Hover over element                             |
| `action/scroll`   | Scroll page or element                         |
| `action/select`   | Select dropdown option                         |
| `action/check`    | Check checkbox                                 |
| `action/uncheck`  | Uncheck checkbox                               |
| `action/upload`   | Upload file to file input                      |
| `action/drag`     | Drag element to target                         |

All action methods accept a `selector` parameter using any of the [10 selector types](/protocol/selectors).

<Accordion title="Common action parameters">
  \| Parameter | Type | Description | |-----------|------|-------------| | `pageId` | `string` |
  Target page (defaults to active page) | | `selector` | `BAPSelector` | Element to interact with |
  \| `timeout` | `number` | Operation timeout in ms |
</Accordion>

## Observations (7)

| Method                  | Description                                  |
| ----------------------- | -------------------------------------------- |
| `observe/screenshot`    | Take screenshot (JPEG default, PNG optional) |
| `observe/accessibility` | Get accessibility tree                       |
| `observe/dom`           | Get page HTML (sensitive content redacted)   |
| `observe/element`       | Get element properties                       |
| `observe/pdf`           | Generate PDF of the page                     |
| `observe/content`       | Get page text, HTML, or markdown             |
| `observe/ariaSnapshot`  | Get ARIA snapshot in YAML format             |

## Storage (5)

| Method                 | Description                    |
| ---------------------- | ------------------------------ |
| `storage/getState`     | Get cookies + localStorage     |
| `storage/setState`     | Set cookies + localStorage     |
| `storage/getCookies`   | Get cookies for current domain |
| `storage/setCookies`   | Set cookies                    |
| `storage/clearCookies` | Clear all cookies              |

## Emulation (4)

| Method                   | Description                   |
| ------------------------ | ----------------------------- |
| `emulate/setViewport`    | Set viewport width and height |
| `emulate/setUserAgent`   | Set custom user agent string  |
| `emulate/setGeolocation` | Set geolocation coordinates   |
| `emulate/setOffline`     | Toggle offline mode           |

## Dialog, Tracing, Events (4)

| Method             | Description                        |
| ------------------ | ---------------------------------- |
| `dialog/handle`    | Accept or dismiss a browser dialog |
| `trace/start`      | Start a Playwright trace recording |
| `trace/stop`       | Stop trace and return data         |
| `events/subscribe` | Subscribe to specific event types  |

## Context (3)

Browser contexts provide isolated sessions with separate cookies and storage.

| Method            | Description                                                            |
| ----------------- | ---------------------------------------------------------------------- |
| `context/create`  | Create new browser context with optional viewport, locale, permissions |
| `context/list`    | List all active contexts                                               |
| `context/destroy` | Destroy a context and all its pages                                    |

## Frame (3)

| Method         | Description                                   |
| -------------- | --------------------------------------------- |
| `frame/list`   | List all frames in the current page           |
| `frame/switch` | Switch to an iframe (by selector or frame ID) |
| `frame/main`   | Switch back to the main frame                 |

## Stream + Approval (2)

| Method             | Description                                     |
| ------------------ | ----------------------------------------------- |
| `stream/cancel`    | Cancel a streaming response                     |
| `approval/respond` | Respond to a human-in-the-loop approval request |

## Discovery (1)

| Method               | Description                                       |
| -------------------- | ------------------------------------------------- |
| `discovery/discover` | Discover WebMCP tools exposed by the current page |

See the [WebMCP guide](/guides/webmcp) for details on tool discovery.

## Agent (3)

The agent methods are composite operations optimized for AI agent workflows. They batch multiple lower-level operations into single requests.

| Method          | Description                                                                                       |
| --------------- | ------------------------------------------------------------------------------------------------- |
| `agent/act`     | Execute a sequence of action steps with retry logic, conditions, and pre/post observation         |
| `agent/observe` | Get an AI-optimized page snapshot with interactive elements, stable refs, and optional annotation |
| `agent/extract` | Extract structured data from the page using a JSON Schema                                         |

<Accordion title="agent/act parameters">
  \| Parameter | Type | Default | Description | |-----------|------|---------|-------------| |
  `steps` | `ExecutionStep[]` | -- | Sequence of steps to execute (1-50) | | `pageId` | `string` |
  active page | Target page | | `stopOnFirstError` | `boolean` | `true` | Halt on first failure | |
  `timeout` | `number` | -- | Global timeout for entire sequence | | `preObserve` |
  `AgentObserveParams` | -- | Run observe before steps (fusion) | | `postObserve` |
  `AgentObserveParams` | -- | Run observe after steps (fusion) |
</Accordion>

<Accordion title="agent/observe parameters">
  \| Parameter | Type | Default | Description | |-----------|------|---------|-------------| |
  `includeAccessibility` | `boolean` | -- | Include full accessibility tree | | `includeScreenshot`
  \| `boolean` | -- | Include base64 screenshot | | `includeInteractiveElements` | `boolean` | -- |
  Include interactive elements with refs | | `maxElements` | `number` | 50 | Max elements to return
  \| | `filterRoles` | `string[]` | -- | Filter to specific ARIA roles | | `responseTier` | `"full"
      \| "interactive" \| "minimal"` | `"full"` | Response compression tier | | `incremental` |
  `boolean` | -- | Return only changes since last observation | | `includeWebMCPTools` | `boolean` |
  \-- | Discover WebMCP tools on the page | | `annotateScreenshot` | `boolean \| AnnotationOptions` |
  \-- | Add Set-of-Marks style annotation |
</Accordion>

<Accordion title="agent/extract parameters">
  \| Parameter | Type | Default | Description | |-----------|------|---------|-------------| |
  `instruction` | `string` | -- | Natural language description of what to extract | | `schema` |
  `ExtractionSchema` | -- | JSON Schema defining the output structure | | `mode` | `"single" \|
      "list" \| "table"` | `"single"` | Extraction mode | | `selector` | `BAPSelector` | -- | Limit
  extraction scope to a container | | `includeSourceRefs` | `boolean` | -- | Include source element
  references |
</Accordion>

## Fusion Operations

Six optimizations that eliminate redundant roundtrips:

| Fusion                   | How It Works                                 | Savings                            |
| ------------------------ | -------------------------------------------- | ---------------------------------- |
| **observe-act-observe**  | `preObserve`/`postObserve` in `agent/act`    | Eliminates 2 extra WebSocket calls |
| **navigate-observe**     | `observe` param in `page/navigate`           | Eliminates 1 extra call            |
| **incremental observe**  | `incremental: true` returns only changes     | Reduces payload size               |
| **selector caching**     | Cached CSS paths for ref lookups             | Faster resolution                  |
| **response tiers**       | `full` / `interactive` / `minimal`           | Up to 80% smaller payloads         |
| **speculative prefetch** | Fire-and-forget observe after click/navigate | Pre-warms cache                    |
