85 / 168 · 01 Agent Skills for Browser Automation · Test Patterns for AI-Driven Browser Automation← prev⊞ allnext →☰ Read as one page
11.11Anti-Patterns
Don't: Hard-Code Wait Times
# BAD
playwright-cli goto https://app.example.com
sleep 5 # Arbitrary wait
playwright-cli snapshot
# GOOD
playwright-cli goto https://app.example.com
playwright-cli snapshot # actions auto-wait; for slow async state,
# poll via eval or re-snapshot with judgment
Don't: Act on Refs from a Stale Snapshot
# BAD: page navigated since the last snapshot
playwright-cli click e5 # e5 belonged to the previous page
# GOOD: re-snapshot after any navigation or major state change
playwright-cli snapshot
playwright-cli click e9 # ref from the current snapshot
Don't: Chain Commands Without Verification
# BAD: Assumes every step succeeds
playwright-cli goto url && playwright-cli click e3 && playwright-cli click e7
# GOOD: Verify each critical step
playwright-cli goto url
playwright-cli snapshot # confirm expected elements exist
playwright-cli click e3
playwright-cli snapshot # confirm the state actually changed
playwright-cli click e7