> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/agent-browser/session-inspection-and-recording.md).

# 会话检查和录制

了解如何通过实时图形界面调试 Oxylabs 智能体浏览器自动化会话。

Oxylabs Agent Browser 提供 [**会话检查**](#session-inspection-vnc) 和 [**会话录制**](#session-recording) 可用于实时观察浏览器自动化，或回看过去会话的视频回放。这些可视化调试功能可让你：

* 诊断仅从日志或错误消息中看不出的复杂问题
* 准确理解页面渲染，就像浏览器看到的一样
* 验证自动化工作流是否正确执行
* 实时排查意外行为

这两个工具可直接在 `hb.oxylabs.io` 该域名下使用，并与你的连接端点并列：

* 仪表板位于 `hb.oxylabs.io/dashboard`
* 会话检查位于 `hb.oxylabs.io/novnc`

{% hint style="warning" %}
**注意：** 仪表板和会话检查工具已从 `headlesify.io` 迁移到 `hb.oxylabs.io`.

请在 **10 月 1 日前**更新你的集成。从那天起，流向旧域名的流量将自动路由到新域名。
{% endhint %}

## 会话检查（VNC） <a href="#session-inspection-vnc" id="session-inspection-vnc"></a>

会话检查工具是一种调试功能，它使用 VNC（虚拟网络计算）为你的浏览器自动化会话提供实时可视访问。

查看实时会话的推荐方式是通过仪表板 `hb.oxylabs.io/dashboard`，你无需额外设置即可查看活动会话。

如果你需要一个直接的查看器链接（例如嵌入到你自己的工具中），你可以获取 `hb.oxylabs.io/novnc` 来自会话 ID 的查看器 URL：

```javascript
const cdp = await ctx.newCDPSession(page);
const { value: sid } = await cdp.send("__session_id");
const vncUrl = `https://hb.oxylabs.io/novnc/?id=${sid}`;
console.log(vncUrl);  // open this URL in your browser
```

{% hint style="warning" %}
**注意：** 会话检查正在全面集成到主仪表板中。迁移完成后，仪表板将成为监控和检查实时会话的唯一位置，本页面也将相应更新。
{% endhint %}

其他 CDP 客户端请参见 [CDP 集成](https://developers.oxylabs.io/products/cn/agent-browser/cdp-ji-cheng.md).

## 会话录制

将整个 Agent Browser 会话录制为视频，用于调试、审计或复查。要录制会话，请添加 `record=true` 该查询参数到你的连接 URL：

```bash
wss://USER:PASS@hb.oxylabs.io?record=true
```

默认情况下，每个账户最多可存储 **10 条录制**。如果你需要更高的限制，请联系 Oxylabs 支持（[在线聊天](https://oxylabs.io/) 或 [电子邮件](mailto:support@oxylabs.io)）或你的专属客户经理。

{% hint style="info" %}
使用 [**持久会话**](https://developers.oxylabs.io/products/cn/agent-browser/persistent-sessions-and-profiles.md#persistent-sessions)时，录制会作为跨该会话所有重连的一段连续视频存储，而不是为每次连接创建单独的录制文件。
{% endhint %}

### 自定义录制名称

通过使用 `record_name` 该参数，在仪表板中使用自定义名称整理和筛选你的视频。你可以使用字母数字字符，并可包含连字符和下划线，最大长度为 64 个字符（`^[a-zA-Z0-9_-]{1,64}$`):

```bash
wss://USER:PASS@hb.oxylabs.io?record=true&record_name=payment_checkout_flow_01
```

### 访问回放

所有已完成的录制都会自动编码并保存到你的仪表板。你可以直接在 `hb.oxylabs.io/dashboard`.

## 代码示例

以下 Node.js 示例展示了如何在启用录制的情况下连接到浏览器、以编程方式提取会话 ID，并将实时检查链接输出到控制台。

{% hint style="success" %}
这些功能同时支持 Playwright 和 Puppeteer 库。
{% endhint %}

```javascript
import { chromium } from "playwright";

const username = "USERNAME_abc12";
const password = "PASSWORD";
const endpoint = "hb.oxylabs.io";
// Enable video recording under a custom name
const params = "record=true&record_name=chrome_vnc_test";
const browserUrl = `wss://${username}:${password}@${endpoint}?${params}`;

(async () => {
    // Connect to the browser
    const browser = await chromium.connectOverCDP(browserUrl);
    const ctx = browser.contexts()[0] || (await browser.newContext());
    const page = ctx.pages()[0] || (await ctx.newPage());
    try {
        // 1. Initialize a CDP session on the active page
        const cdpSession = await ctx.newCDPSession(page);
        
        // 2. Query the custom session identifier
        const { value: sessionId } = await cdpSession.send("__session_id");
        
        // 3. Construct and output the session inspection link
        console.log(`Live session inspection link: https://hb.oxylabs.io/novnc/?id=${sessionId}`);
        // Execute your automation steps
        await page.goto("https://example.com");
        
        // Hold session open briefly to allow visual monitoring
        await new Promise(resolve => setTimeout(resolve, 10000));
    } catch (error) {
        console.error("Visual session execution failed:", error.message);
    } finally {
        await browser.close();
        console.log("Recording compiled. Access playback at https://hb.oxylabs.io/dashboard");
    }
})();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/cn/agent-browser/session-inspection-and-recording.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
