Appearance
Playwright Automation
Connect Playwright to Multilogin X browser profiles using Chrome DevTools Protocol (CDP).
Starting a Profile with Playwright
Start a browser profile with automation_type=playwright:
bash
curl "https://launcher.mlx.yt:45001/api/v1/profile/f/FOLDER_ID/p/PROFILE_ID/start?automation_type=playwright" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"The response contains connection details for Playwright's CDP connection.
Connecting with Python Playwright
python
import asyncio
from playwright.async_api import async_playwright
async def main():
# Get the CDP URL from profile start response
cdp_url = "ws://127.0.0.1:PORT/devtools/browser/BROWSER_ID"
async with async_playwright() as p:
# Connect to running Multilogin profile
browser = await p.chromium.connect_over_cdp(cdp_url)
# Get the default context
context = browser.contexts[0]
page = context.pages[0] if context.pages else await context.new_page()
# Automate
await page.goto("https://example.com")
print(await page.title())
# Disconnect (profile stays open)
await browser.close()
asyncio.run(main())Node.js Playwright
javascript
const { chromium } = require('playwright');
(async () => {
const cdpUrl = 'ws://127.0.0.1:PORT/devtools/browser/BROWSER_ID';
const browser = await chromium.connectOverCDP(cdpUrl);
const context = browser.contexts()[0];
const page = context.pages()[0] || await context.newPage();
await page.goto('https://example.com');
console.log(await page.title());
await browser.close();
})();Playwright Workflow
Playwright vs Selenium
| Feature | Selenium | Playwright |
|---|---|---|
| Protocol | WebDriver | CDP (Chrome DevTools) |
| Languages | Python, Java, JS, etc. | Python, JS, .NET, Java |
| Speed | Standard | Faster (CDP direct) |
| Auto-wait | Manual | Built-in |
| Multiple browsers | Yes | Yes |
| Best for | Legacy, broad compat | Modern automation |
Best Practices
- Use
connect_over_cdp(notlaunch) to attach to Multilogin profiles - Access existing contexts and pages rather than creating new ones
- Use Playwright's auto-wait features instead of manual sleeps
- Disconnect cleanly when done to avoid orphaned connections