D>DemoCI
Updated November 29, 2026 • 2027 Guide

How to Record Authenticated Playwright Product Demos in CI (OAuth, 2FA & CDP) — 2027 Guide

Step-by-step 2027 engineering pattern to record authenticated SaaS dashboards in GitHub Actions without flaky OAuth logins using storageState, CDP, and YAML route mocking.

Direct Answer (2027 Summary)

How do you record Playwright product demos behind OAuth and 2FA in CI?

Avoid automating brittle OAuth or 2FA forms inside CI pipelines. Save an authenticated Playwright session once via npx @shipcraftlabs/democi auth save, inject base64 state with DEMOCI_STORAGE_STATE_B64, connect to localhost via --cdp-url when needed, and mock external payment iframes with YAML routes.

1. Save Auth State Locally Once (Zero Password Typing in CI)

Modern SaaS logins block headless bots with Google OAuth, passkeys, and SMS/TOTP 2FA challenges. Instead of hardcoding login steps in CI, log in once manually through Chromium and export cookies + localStorage via storageState.

npx @shipcraftlabs/democi auth save https://app.yourproduct.com --out auth.json
# Encode and store auth.json in GitHub Actions Secrets as DEMOCI_STORAGE_STATE_B64

2. Inject Sessions & Mock Flaky Iframes Deterministically

Inside GitHub Actions, set DEMOCI_STORAGE_STATE_B64 alongside YAML routes mocking and ${ENV_VAR} extraHTTPHeaders in democi.yml so Stripe Elements, usage charts, or webhooks always render crisp deterministic state.

name: "Authenticated Workspace Demo"
baseUrl: https://staging.yourproduct.com
headers:
  Authorization: "Bearer ${DEMO_API_TOKEN}"
routes:
  - url: "**/api/billing/summary"
    status: 200
    body: '{"plan":"Team","status":"active"}'
steps:
  - id: open-analytics
    title: "Inspect real-time deployment metrics"
    description: "Sensitive customer emails stay masked pre-capture."
    selector: '[data-testid="analytics-chart"]'
    mask: ['.customer-email']
    action: observe

3. Attach Directly to Local Chrome via CDP (--cdp-url)

When recording locally against an already signed-in browser tab (e.g., localhost staging or VPN-gated internal admin dashboards), attach DemoCI over Chrome DevTools Protocol without closing your host browser window.

npx @shipcraftlabs/democi run democi.yml --cdp-url http://127.0.0.1:9222

Frequently Asked Questions (2027)

Can Playwright mask customer PII before saving screenshots or MP4 video?

Yes. Adding mask selectors such as .customer-email in democi.yml or demo.step() redacts DOM elements directly inside Playwright before any screenshot frame or video frame is captured.

Does --cdp-url kill my existing Chrome session when finished?

No. DemoCI v0.2.1 detects connectOverCDP mode, reuses the existing browser context cleanly, and disconnects without closing your host Chrome process.

Try DemoCI v0.2.1 on Your Repo Today

Free open CLI forever or start a 14-day free trial ($0 today, then $49/mo Founding Team, unlimited seats).