Feature status: BROWSER-001 in the canonical register.
Backlog / proposal. Browser automation is not covered by real E2E tests in CI.
The posting, engagement, sessions, and replies modules depend on live X / Threads / Facebook pages. The test suite mocks the browser, so selector drift, CAPTCHA, and third-party JS errors are only caught during pnpm dry-run or live runs. There is no way to record a successful dry-run and replay it in CI or during onboarding.
browser.factory.tsmanages Camoufox/Firefox contexts, applies memory prefs, resource blocking, and patchesplaywright-corefor Camoufox compatibility.- Selectors are resolved through a fallback chain in
selector-health.service.tsand concrete poster implementations (x.poster.ts,threads.poster.ts,facebook.poster.ts). - E2E tests (
tests/e2e/posting-flow.e2e.spec.ts, etc.) mock the browser and assert high-level flows, not selectors. pnpm dry-runopens a real browser and intercepts the final submit, but the result is not captured as a replay artifact.
<ref_snippet file="/Users/valentinyakovlev/projects/agents/social-poster-agent/packages/backend/src/infrastructure/browser/browser.factory.ts" lines="1-40" />
- Recording mode. Add a
RECORDING_DIRenv var. Duringpnpm dry-run, the harness records:- Resolved selector chains per action.
- Page URLs and navigation sequence.
- Text input values (sanitized, no passwords).
- Screenshot before/after each action.
- Network errors / uncaught JS errors encountered.
- The final intercepted post URL and HTTP status.
- Scenario file format. JSONL or YAML scenario in
tests/e2e/scenarios/, e.g.:network: X url: https://x.com/compose/post steps: - action: fill selector: "[data-testid='tweetTextarea_0']" value: "Sample text" - action: click selector: "button[data-testid='tweetButtonInline']" expect: "https://x.com/*/status/*"
- Replay engine. A
BrowserReplayService(or extension ofBrowserFactory) that replays recorded selectors against a headless browser in CI. Uses patched Playwright and Camoufox. On mismatch, saves a diff screenshot and logs the drift. - Selector health integration.
selector-health.service.tscan compare recorded vs. live resolved selectors and emit a warning when a platform changed adata-testid. - Nightly CI job.
pnpm test:e2e:browserruns against staging accounts, posts to a private test account, and reports drift.
infrastructure/browser/browser.factory.ts— recording and replay hooks.infrastructure/browser/browser.port.ts— addrecordScenario()/replayScenario()methods.modules/posting/posters/*.poster.ts— emit action events during dry-run.tests/e2e/— new replay-based specs.packages/backend/scripts/patch-playwright.js— keep up to date with Playwright versions.
- Recording live sites means scenarios will break frequently; the replay engine must be tolerant to selector drift.
- Storing screenshots in CI artifacts may consume space; keep only failures and last 7 days.
- Test accounts on X/Threads/Facebook are fragile and may be suspended.
- Passwords/cookies must never be committed; use env vars and
storageStatein ephemeral CI.
L (3–6 weeks). Recording is relatively easy; reliable, non-flaky replay against live platforms is the hard part.
infrastructure-browser.mdposting.mdengagement.mdreplies.md