Brifing

Webwright: Why AI Web Agents Should Write Code Instead of Clicking

Microsoft's novel approach nearly doubles success rates in long-horizon web tasks.

Towards Data Science3 min

1The Problem with Traditional Web Agents

Current web agents operate through single-click actions, achieving only 33.5% success rate on long tasks. Around step 40, unexpected pop-ups or page structure changes often derail the process. The core issue lies in agents' step-by-step progression without durable plans, requiring them to wait for new states after each action.

2Competitive Solutions and Limitations

While OpenAI's Operator and Anthropic's Computer Use rely on screenshots, WebVoyager utilizes DOM structure. Benchmarks like Mind2Web provide standardized action sets but don't solve the fundamental problem: agents still perform one operation at a time. Open-source tools like Skyvern package these approaches into APIs but fail to produce reusable outputs.

3Webwright's Revolutionary Approach

Developed by Microsoft Research and University of Hong Kong, Webwright grants agents terminal access to write bash and Playwright scripts. This approach boosts GPT-5.4's success rate to 60.1% on long-horizon tasks. Instead of click traces, it generates command-line tools that engineers can inspect and reuse.

4Technical Infrastructure and Components

Webwright consists of three core components: code generator, error corrector, and executor. This ~1000-line framework is optimized for page inspection and task execution. It particularly excels with JavaScript-heavy sites, infinite scroll pages, and paginated content. By writing code instead of interacting with DOM, it's less affected by page structure changes.

5Cost and Performance Advantages

While screenshot-based systems consume tokens with each new image, Webwright's code-based approach reduces context costs. On VisualWebArena, human success reaches 89% while visual agents achieve only 16%. Webwright outperforms WebVoyager's reported 59% success rate across 50 real-world websites.

6Implementation Scenarios

Webwright makes significant impact in three scenarios: automated navigation through paginated content, scraping JavaScript-rendered dynamic data, and collecting data from infinite-scroll feeds. It's ideal for workflows requiring reusable solutions, like e-commerce catalogs, internal tools, and data dashboards.

7Challenges of DOM-Based Systems

DOM and accessibility-tree based agents solve screenshot issues but introduce new challenges. Complex pages can generate accessibility trees exceeding 50KB. Element references change when pages reload or lazy-load content. Webwright's code-based approach eliminates this unnecessary data overhead.

8Limitations of Fixed Action APIs

Fixed action sets (click, type, scroll) constrain agents' expressive power. They can't naturally articulate high-level instructions like "proceed until last page" or "collect 1000 rows." Webwright's code generation automatically converts these into loops and conditional statements for smarter automation.

9Reusability Advantage

While traditional agents leave only click sequences, Webwright produces executable scripts. Engineers can examine, modify, and reuse these across different tasks. This offers significant time savings especially for enterprise applications using web as data source.

10Industry Impact and Future

Webwright's approach could reshape the future of RPA and web scraping tools. Instead of dominant click-based solutions, code-generating systems are expected to proliferate in 2024. Microsoft reportedly plans to offer this technology as an Azure service.

11Comparative Benchmark Results

In tests with GPT-5.4 model, Webwright achieved 60.1% success rate on long-horizon tasks—nearly double traditional methods. While the difference is smaller for short tasks, it significantly outperforms in 100+ step processes. The system also provides cost advantage by consuming 40% fewer tokens.

12Key Takeaway and Significance

Webwright offers a paradigm shift in web automation: targeting the root cause (lack of persistent plans) rather than symptoms (single-click errors). Code generation capability not only increases success rates but delivers outputs integrable into engineering processes. It holds potential to revolutionize all scenarios where web serves as data source.

Original article: Towards Data Science — Webwright: AI Web Ajanları Neden Tıklamak Yerine Kod Yazmalı?