docs: Playwright-native mode, shadow DOM guide, and demo scripts (Phase 5–8)

Closed
KI
7mo ago
+1801-6

Summary

  • New page: v3/configuration/playwright-native — full guide for browserContext option, camoufox/Firefox setup, page-passing requirement, caching behaviour, and mode comparison table
  • New page: v3/best-practices/shadow-dom — open + closed shadow root automation, attachShadow interceptor pattern, enterprise app troubleshooting (SAP, Salesforce, ServiceNow)
  • stagehand.mdx — adds browserContext to V3Options interface block and <ParamField> section
  • act / extract / observe refs — page type updated to include PlaywrightNativePage; note that page must be passed explicitly in native mode
  • configuration/browser.mdx — new "Playwright-Native Mode" section with camoufox quickstart and cacheDir / logger notes
  • best-practices/caching.mdx — new native-mode caching section and logger snippet for detecting local cache hits
  • docs.json — playwright-native added to Configuration group; shadow-dom added to Best Practices group
  • Demo scripts (packages/core/examples/v3/):
    • demo_01_caching.ts — act() cold/warm cache comparison using logger interception
    • demo_02_camoufox_extract.ts — camoufox + observe() + extract() end-to-end
    • demo_03_shadow_dom.ts — pierceShadow: true vs "including-closed" diff with live node counts

Test plan

  • Mintlify preview renders both new pages without broken links
  • v3/configuration/playwright-native appears under Configuration in sidebar
  • v3/best-practices/shadow-dom appears under Best Practices in sidebar
  • stagehand.mdx shows browserContext ParamField
  • act/extract/observe refs show PlaywrightNativePage in page type union
  • pnpm example v3/demo_01_caching runs (requires OPENAI_API_KEY)
  • pnpm example v3/demo_03_shadow_dom runs (headless, no API key needed)

Closes #17

🤖 Generated with Claude Code


Summary by cubic

Adds full docs for Playwright‑native mode and closed Shadow DOM automation, plus three runnable demos to showcase caching, camoufox/Firefox, and shadow‑piercing.
Clarifies the browserContext option, the need to pass page in native mode, and how local caching works with logger hints.

  • New Features

    • New docs pages: v3/configuration/playwright-native and v3/best-practices/shadow-dom.
    • Updated docs: stagehand reference adds browserContext; act/extract/observe reference pages include PlaywrightNativePage and note the explicit page requirement; configuration/browser adds a Playwright‑native section; caching guide documents native‑mode local cache and a logger snippet; navigation updated in docs.json.
    • New demos in packages/core/examples/v3/: demo_01_caching.ts (cold vs warm cache), demo_02_camoufox_extract.ts (camoufox + observe/extract), demo_03_shadow_dom.ts (open vs closed shadow diff).
  • Migration

    • No breaking changes. When using browserContext, always pass the Playwright page to act()/extract()/observe().
    • For closed shadow roots, install the attachShadow interceptor via addInitScript before navigation to enable "including-closed" piercing.