Modern QA2026Strategy 2: CLI by Default, Re-snapshot as Fallback, MCP for No-Disk Environments — tiles
Log inJoin
61 / 168 · 01 Agent Skills for Browser Automation · Hybrid Strategies: Using Skills and MCP Together← prev⊞ allnext →☰ Read as one page

9.3Strategy 2: CLI by Default, Re-snapshot as Fallback, MCP for No-Disk Environments

The Pattern

# Pseudocode for the agent's behavior
try:
    # Primary: act on a known ref (fast, cheap)
    playwright-cli click e5
except StaleOrMissingRef:
    # Fallback: refresh understanding from disk
    playwright-cli snapshot
    # Agent reads the new YAML, finds "Sign in" button's new ref
    playwright-cli click e9

# Separately: if this flow must also run from a sandboxed surface
# with no filesystem, route that environment through Playwright MCP.

Token Cost

Happy path (ref works):        ~55 tokens
Fallback path (re-snapshot):   ~2,000-5,000 tokens (one snapshot read + retry)
Average (assuming 90% success): a few hundred tokens per step

When to Use

  • Mature test suites where most flows are stable
  • Self-healing tests that adapt when the UI changes (see the Self-Healing Strategies chapter — Playwright's healer agent productizes exactly this loop)
  • Cost optimization — pay for page state only when something breaks