> 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`，你无需额外配置即可查看活动会话。

如果你需要直接的查看器链接（例如嵌入到你自己的工具中），你可以从会话 ID 中获取 `hb.oxylabs.io/novnc` 查看器 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 集成](/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" %}
在使用 [**持久会话**](/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.
