Skip to content

Puppeteer Automation

Connect Puppeteer to Multilogin X browser profiles using Chrome DevTools Protocol.

Starting a Profile with Puppeteer

Start a browser profile with automation_type=puppeteer:

bash
curl "https://launcher.mlx.yt:45001/api/v1/profile/f/FOLDER_ID/p/PROFILE_ID/start?automation_type=puppeteer" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"

Connecting with Puppeteer

javascript
const puppeteer = require('puppeteer-core');

(async () => {
    // Get WebSocket URL from profile start response
    const wsEndpoint = 'ws://127.0.0.1:PORT/devtools/browser/BROWSER_ID';

    // Connect to running profile
    const browser = await puppeteer.connect({
        browserWSEndpoint: wsEndpoint
    });

    // Get existing pages or create new
    const pages = await browser.pages();
    const page = pages[0] || await browser.newPage();

    // Automate
    await page.goto('https://example.com');
    console.log(await page.title());

    // Take screenshot
    await page.screenshot({ path: 'screenshot.png' });

    // Disconnect (profile stays open)
    browser.disconnect();
})();

Puppeteer Workflow

Important Notes

  • Use puppeteer-core (not puppeteer) since you are connecting to an existing browser
  • Use puppeteer.connect() with browserWSEndpoint -- do not use puppeteer.launch()
  • Use browser.disconnect() instead of browser.close() to keep the profile running
  • The WebSocket URL comes from the profile start response or the debugger URL endpoint

Best Practices

  • Always use puppeteer-core to avoid downloading bundled Chromium
  • Handle page lifecycle events for reliable automation
  • Use page.waitForNavigation() or page.waitForSelector() instead of delays
  • Clean up by disconnecting when done