14 / 108 · 03 Agentic Testing Architectures · Mapping ReAct to CLI Browser Commands← prev⊞ allnext →☰ Read as one page
2.5Error Recovery Patterns
One of the most powerful aspects of mapping ReAct onto a CLI is the agent's ability to recover from errors:
Stale Ref Recovery
Agent tries: playwright-cli click e11
Output: ERROR: ref e11 not found (page changed since last snapshot)
Agent observes: playwright-cli snapshot
→ button "Submit" is now [ref=e31]
Agent reasons: "The page re-rendered and refs changed. The submit button
is now e31."
Agent acts: playwright-cli click e31
Output: success
Unexpected State Recovery
Agent tries: playwright-cli click e24 # checkout button
Output: success
Agent observes: playwright-cli snapshot
→ heading "Your session has expired. Please log in again."
Agent reasons: "Session expired during checkout. This is an environment
issue. I need to log in again before continuing the test."
Agent acts:
playwright-cli state-load auth-state # restore saved login state
playwright-cli goto "https://app.example.com/checkout"
// Then retries the checkout