import { chromium } from "playwright";
const username = "USERNAME_abc12";
const password = "PASSWORD";
const endpoint = "ubc.oxylabs.io";
// Enable VNC stream and video recording under a custom name
const params = "o_vnc=true&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 VNC viewer link
console.log(`Live VNC Link: https://vnc.headlesify.io/novnc/?id=${sessionId}`);
// Execute your automation steps
await page.goto("https://example.com");
// Hold session open briefly to allow visual monitoring via VNC link
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://dashboard.headlesify.io/#recordings");
}
})();