Playwright integration

Automate the same persistent profile your team uses.

AliasMode starts a configured browser profile and returns a CDP WebSocket URL. Playwright attaches to that active profile with its stored session, proxy, and settings.

Local API (HTTP) — Playwright CDP — Windows — Tested 2026-08-10

Set up Playwright

  1. Enable the Local API

    Enable the Local API in AliasMode and keep the desktop app running while the profile is active.

  2. Start the profile with its user_id

    Call the browser start route with the profile's user_id, found with GET /api/v1/user/list.

    import { chromium } from 'playwright';
    
    const origin = 'http://127.0.0.1:50400';
    // Find this ID with GET /api/v1/user/list.
    const profileId = process.env.ALIASMODE_PROFILE_ID;
    if (!profileId) throw new Error('Set ALIASMODE_PROFILE_ID');
    
    const startUrl = new URL('/api/v1/browser/start', origin);
    startUrl.searchParams.set('user_id', profileId);
    
    let browser;
    let started = false;
    try {
      const startResponse = await fetch(startUrl);
      if (!startResponse.ok) {
        throw new Error(`AliasMode returned HTTP ${startResponse.status}`);
      }
    
      const payload = await startResponse.json();
      const cdpUrl = payload?.data?.ws?.puppeteer;
      if (payload?.code !== 0 || typeof cdpUrl !== 'string') {
        throw new Error(payload?.msg || 'AliasMode did not return a CDP URL');
      }
    
      started = true;
      browser = await chromium.connectOverCDP(cdpUrl);
      // Run automation with the connected browser.
    } finally {
      try {
        await browser?.close();
      } finally {
        if (started) {
          const stopUrl = new URL('/api/v1/browser/stop', origin);
          stopUrl.searchParams.set('user_id', profileId);
          await fetch(stopUrl);
        }
      }
    }
  3. Read the CDP endpoint

    Read response.data.ws.puppeteer from the start response.

  4. Connect Playwright over CDP

    Call chromium.connectOverCDP with the returned WebSocket URL to attach to the active profile.

  5. Give one owner to the active profile

    Give one operator or automation job ownership of an active profile so work does not overlap.

Verify the connection

  • The start route returns HTTP 200 with code 0 in the JSON envelope.
  • response.data.ws.puppeteer is a valid CDP WebSocket URL.
  • chromium.connectOverCDP attaches without creating a new temporary context.
  • The profile stops cleanly after Playwright disconnects.

Troubleshooting

SymptomFix
connectOverCDP fails or times outConfirm the desktop app is open, the status route responds, and the profile ID exists before retrying.
The start response has no ws.puppeteer valueTreat a missing CDP URL as a failed start; check the HTTP status and response code and message.
Two automations open the same profileGive one operator or automation job ownership of an active profile to avoid overlapping actions.

Where the integration fits

Use this connection for internal QA, approved account operations, repeatable browser checks, and workflows that need a persistent signed-in profile rather than a new temporary context.