Credentials & Login

Advanced browser profile management for custom Playwright/Selenium integrations.

Note: For most users, the InverseUI CLI handles profile management automatically. Use these recipes only if you need custom configurations.

Option 1: Attach to an Existing Chrome

Use your own Chrome with all your login sessions, extensions, and cookies. Start it with a debugging port, then let Playwright attach and drive that exact browser.

Step 1: Find your Chrome profile path

Navigate to chrome://version in Chrome and find the Profile Path:

Profile Path    /Users/yourname/Library/Application Support/Google/Chrome/Profile 2

Step 2: Copy your profile (one-time setup)

Chrome doesn't allow remote debugging on the default data directory. Copy your profile to a new location:

# macOS
mkdir -p "$HOME/inverseui"
cp -R "$HOME/Library/Application Support/Google/Chrome/Profile 2" "$HOME/inverseui/Profile 2"

# Linux
mkdir -p "$HOME/inverseui"
cp -R "$HOME/.config/google-chrome/Profile 2" "$HOME/inverseui/Profile 2"

# Windows (PowerShell)
mkdir "$env:USERPROFILE\inverseui"
Copy-Item -Recurse "$env:LOCALAPPDATA\Google\Chrome\User Data\Profile 2" "$env:USERPROFILE\inverseui\Profile 2"

Replace Profile 2 with your actual profile folder name from Step 1.

Step 3: Start Chrome with debugging enabled

Launch Chrome pointing to your copied profile with remote debugging enabled:

# macOS
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
  --remote-debugging-port=9222 \
  --user-data-dir="$HOME/inverseui" \
  --profile-directory="Profile 2"

# Linux
google-chrome \
  --remote-debugging-port=9222 \
  --user-data-dir="$HOME/inverseui" \
  --profile-directory="Profile 2"

# Windows (cmd)
"C:\Program Files\Google\Chrome\Application\chrome.exe" ^
  --remote-debugging-port=9222 ^
  --user-data-dir="%USERPROFILE%\inverseui" ^
  --profile-directory="Profile 2"

What these flags do:

  • --remote-debugging-port=9222 — Enables the Chrome DevTools Protocol
  • --user-data-dir — Points to the directory containing your copied profile
  • --profile-directory — Specifies which profile folder to use

Step 4: Attach with Playwright

# attach_existing.py
import asyncio
from playwright.async_api import async_playwright

CDP_URL = "http://localhost:9222"

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.connect_over_cdp(CDP_URL)
        ctx = browser.contexts[0] if browser.contexts else await browser.new_context()
        page = ctx.pages[0] if ctx.pages else await ctx.new_page()

        # Already logged in to whatever sites you used in that Chrome
        await page.goto("https://example.com")
        # ... InverseUI-generated steps ...

        # ⚠ don't browser.close(), that would kill your Chrome

if __name__ == "__main__":
    asyncio.run(main())

Option 2: Persistent Profile

Use a persistent browser profile for your project. On the first run, log into the sites you need (GitHub, LinkedIn, internal tools…). All sessions are saved and reused in subsequent runs.

First run: Browser opens → log into any sites you need → sessions saved to .inverseui/profile

Subsequent runs: Already logged in, automation runs immediately.

import asyncio
from pathlib import Path
from playwright.async_api import async_playwright

PROFILE_DIR = Path(".inverseui/profile")

async def main():
    async with async_playwright() as p:
        ctx = await p.chromium.launch_persistent_context(
            user_data_dir=str(PROFILE_DIR),
            headless=False,
        )
        page = ctx.pages[0] if ctx.pages else await ctx.new_page()

        # Navigate to your target site
        await page.goto("https://example.com/login")

        # Your automation code here...

        await ctx.close()

if __name__ == "__main__":
    asyncio.run(main())