Session Inspection
See how to debug automation sessions via a real-time graphical interface.
When to use it?
Usage example
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:[email protected]?o_vnc=true');
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);
}
})();Last updated
Was this helpful?

