First posted on LinkedIn, August 15, 2025.
---
Building autonomous AI agents that can navigate complex web applications through browser automation is hard. Really hard. We learned this while creating a three-agent system (Requester, Approver, Buyer) that orchestrates material requests through an enterprise portal—without any human intervention.
After countless hours debugging why dropdowns wouldn't select, why buttons stayed disabled, and why our agents kept failing at 3am, we've distilled our battle scars into 11 design patterns that will save you time, sanity, and that feeling of wanting to throw your laptop out the window.
## Why Screenshots?
Because one screenshot—`05_buyer_supplier_name_not_found.png`—saved us 6 hours of debugging. It revealed that what we thought was an `` field was actually a complex React component pretending to be one. That single image taught us more than any log file ever could.
## The 11 Patterns
### S — Screenshot Everything Like a Crime Scene
Every action needs forensic evidence. Before click. After click. On error. Always.
Screenshot `05_buyer_supplier_name_not_found.png` revealed our "input field" was actually a `
### C — Click Through Dropdowns Step by Step
Modern dropdowns aren't dropdowns—they're distributed systems.
What we thought would work: `supplier_dropdown.select_option("Abacus Consulting")` — NOPE.
What actually worked required 6 steps: click the trigger, wait for portal animation, find the search input (different element!), fill it, wait for debounced search, then click the option.
### R — Randomize Data to Reveal Edge Cases
Hardcoded test data is a bug's best friend. Our requestor agent worked perfectly with "TEST-001" and always the same department. Then it failed in production with real data.
Randomization revealed: Purchasing routes require buyer assignment. Some departments have dropdown validation. Certain part number formats trigger additional fields.
### E — Expect Two-Phase Commits
The #1 time waster: not realizing UIs have "stage" and "commit" phases.
We clicked "Assign Supplier" and saw it appear in the modal. But after closing the modal, the supplier was gone. We were missing the "Save" click—the supplier was staged but not committed.
### E — Engineer Triple-Redundant Selectors
Your selector will break. Have backups. We had to evolve through 4 selector versions as the React component changed.
Our final redundant approach tries multiple selectors: optimistic (exact match), text-based, test ID, contextual, and last resort. Log which selector succeeded for debugging.
### N — Navigate State Machines, Not Scripts
Your agent isn't following a script—it's navigating a state machine with rules.
Our approver agent kept failing because we tried to assign a buyer before setting routing. The buyer dropdown was disabled—the UI was teaching us business logic. Buyer assignment is only required (and only enabled) when items are routed to Purchasing.
### S — Specify Explicit Waits with Reasons
Every wait needs a documented purpose. Bad: `time.sleep(2)`. Good: `wait(1500) # Portal animation`.
Types of waits: Animation (300-500ms), Debounce (1000-2000ms), Network (2000-5000ms), React re-render (100-500ms).
### H — Hunt Error Messages for Business Rules
Error messages are free documentation. "Buyer is required when one or more items are routed to purchasing" taught us the entire workflow.
### O — Own One State Transition Per Agent
Clear ownership prevents confusion. Each agent owns exactly one state transition. When a request is stuck in "APPROVED", only debug BuyerAgent.
### T — Test Locally, Then Deploy to Cloud
Local for debugging, cloud for scaling. Debugging the supplier dropdown locally: 100 seconds. Same debugging on BrowserStack: 200 seconds (100% slower due to latency).
### S — Serve Agent-Friendly HTML
Design for agents from day one. If your agent can't understand your UI, neither can screen readers (accessibility), search engines (SEO), or browser extensions.
## The Bigger Picture
The harder something is to automate, the harder it is for users. Our supplier dropdown struggle revealed a genuine UX problem that human users were also experiencing but not reporting.
---
Built with Claude Code, Playwright, Python, and way too much coffee.