Modern QA2026The Phase-to-Command Mapping — tiles
Log inJoin
11 / 108 · 03 Agentic Testing Architectures · Mapping ReAct to CLI Browser Commands← prev⊞ allnext →☰ Read as one page

2.2The Phase-to-Command Mapping

ReAct Phase Testing Activity Playwright CLI Commands
Observe Read the current page state playwright-cli snapshot (YAML with element refs, saved to disk), playwright-cli screenshot, playwright-cli eval "<js>"
Think Decide what to test based on observation Agent reasons internally (no command — LLM inference)
Act Execute the test action playwright-cli fill <ref> "<text>", playwright-cli click <ref>, playwright-cli goto "<url>", playwright-cli press <key>
Evaluate Check the result against expectations Fresh snapshot + read it, eval for dynamic state

Observation Commands in Detail

The observation phase is about gathering state. The CLI's key design choice: state lands on disk, and the agent reads only what it needs:

# Save a structured page snapshot (YAML accessibility summary with refs)
playwright-cli snapshot
# → .playwright-cli/snapshot-....yml — the agent Reads this file on demand

# Capture visual state
playwright-cli screenshot

# Query dynamic state directly
playwright-cli eval "document.querySelectorAll('.error').length"
playwright-cli eval "location.href"

A snapshot looks like:

- textbox "Email" [ref=e8]
- textbox "Password" [ref=e9]
- button "Sign In" [ref=e11]
- link "Forgot Password?" [ref=e12]

Element refs (e8, e11) are how the agent addresses elements in the Act phase — no CSS selector authoring.

Action Commands in Detail

# Navigation
playwright-cli open "https://app.example.com/login"
playwright-cli goto "https://app.example.com/settings"

# Form interaction (refs come from the latest snapshot)
playwright-cli fill e8 "user@test.com"
playwright-cli fill e9 "secret123"
playwright-cli select e14 "United States"

# Clicking
playwright-cli click e11
playwright-cli dblclick e20

# Keyboard
playwright-cli press Enter
playwright-cli press Control+a

# Other input
playwright-cli hover e17
playwright-cli check e21
playwright-cli upload e23 ./fixture.pdf

Auto-waiting is built into the engine — every action waits for the element to be actionable, so the agent doesn't hand-roll waits.