> 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/pt-br/headless-browser/features/session-inspection.md).

# Inspeção de Sessão

A **Inspeção de Sessão** é um poderoso **recurso de depuração** do Oxylabs Headless Browser que utiliza a tecnologia VNC (Computação de Rede Virtual) para fornecer acesso visual em tempo real às suas sessões de automação do navegador. Esta ferramenta cria uma ponte segura entre sua instância de Headless Browser e uma interface gráfica que você pode observar e controlar.

### Quando usá-la?

Embora o Oxylabs Headless Browser ofereça recursos de privacidade integrados, tratamento dinâmico de CAPTCHA e outros recursos, certos cenários exigem observação visual direta para:

* Diagnosticar समस्यas complexas que não são evidentes nos logs ou mensagens de erro
* Entender a renderização da página exatamente como o navegador a vê
* Verificar a execução correta dos seus fluxos de automação
* Solucionar comportamentos inesperados em tempo real

### Exemplo de uso

Você pode habilitar a ferramenta Inspeção de Sessão adicionando o `o_vnc=true` parâmetro ao endpoint de conexão, por exemplo:

* **Navegador Chrome:** `wss://username:password@ubc.oxylabs.io?o_vnc=true`
* **Navegador Firefox:** `wss://username:password@ubs.oxylabs.io?o_vnc=true`

{% hint style="success" %}
Este recurso funciona com as bibliotecas Playwright e Puppeteer.
{% endhint %}

{% tabs %}
{% tab title="Chrome (UBC)" %}

```javascript
const {chromium} = require('playwright');

(async () => {
    let page = null;
    let browser = null;

    try {
        // Use o_vnc=true parameter to connect
        browser = await chromium.connectOverCDP('wss://user:pass@ubc.oxylabs.io');
        const ctx = browser.contexts()[0];

        // Create a new page
        page = await ctx.newPage();
        page.on('console', async msg => {
            console.log(`BROWSER [${msg.type()}] ${msg.text()}`);
        });

        // Get the session ID using a CDP session
        let sesId = await (await ctx.newCDPSession(page)).send("__session_id");
        // Use UB novnc client or any WebSocket capable client to connect to vnc
        console.log(`Connect to VNC: https://vnc.headlesify.io/novnc/?id=${sesId.value}`);

        // Goto to a page
        await page.goto('https://duckduckgo.com');

        // Sleep for 10 minutes
        await new Promise(resolve => {
            setTimeout(resolve, 6000000);
        });
    }
    catch (e) {
        console.log("Finished with error:", e);
    } finally {
        if (page != null) await page.close();
        if (browser != null) await browser.close();
        process.exit(0);
    }
})();
```

{% endtab %}

{% tab title="Firefox (UBS)" %}

```javascript
const { firefox } = require('playwright');

(async () => {
    let page = null;
    let browser = null;

    try {
        // Use o_vnc=true parameter to connect
        browser = await firefox.connect('wss://user:pass@ubs.oxylabs.io?o_vnc=true');
        const ctx = await browser.newContext();

        // Create a new page
        page = await ctx.newPage()
        page.on('console', async msg => {
            console.log(`BROWSER [${msg.type()}] ${msg.text()}`);
        })

        // Get the session ID using a CDP session
        let sesId = await (await ctx.newCDPSession(page)).evaluate("__session_id")
        // Use UB novnc client or any WebSocket capable client to connect to VNC
        console.log(`Connect to VNC: https://vnc.headlesify.io/novnc/?id=${sesId.value}`);

        // Goto to a page
        await page.goto('https://duckduckgo.com');

        // Sleep for 10 minutes
        await new Promise(resolve => {
            setTimeout(resolve, 6000000);
        })
    }
    catch (e) {
        console.log("Finished with error:", e);
    } finally {
        if (page != null) await page.close();
        if (browser != null) await browser.close();
        process.exit(0);
    }
})();
```

{% endtab %}
{% endtabs %}


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.oxylabs.io/products/pt-br/headless-browser/features/session-inspection.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
