Cubicles
Cubicles

AI agents vs Playwright, Selenium and RPA: which browser automation should you use?

Scripted automation does the same thing a million times. An AI agent does a different thing once. Most real workflows need a bit of both.

Blog ·

For twenty years, automating a website meant writing a script: find the element with this ID, click it, type this, wait for that. Then AI agents arrived that can look at a page they've never seen and work out what to do. It's tempting to think scripts are finished. They aren't. Each approach wins at different jobs.

The short answer

  • Use a script (Playwright, Selenium, Puppeteer) for the same steps on the same site, many times: testing, high-volume data entry, regular exports.
  • Use RPA (UiPath, Automation Anywhere, Power Automate) for business processes across older desktop and web apps, where audit trails and central control matter.
  • Use an AI agent for the long tail: many different sites, one-off tasks, messy forms, and steps that need judgement.
  • Combine them: let the agent explore and write the script, then run the script; call the agent only when the script breaks.

Three kinds of browser automation

Scripts. Playwright, Selenium and Puppeteer are code libraries that drive a browser. You write each step, usually by pointing at elements on the page. They're fast, free and exact, and they break when the page changes.

RPA. Robotic process automation tools record and replay business processes, often across several apps, with visual editors, scheduling and governance built in. They're common in large companies, and mostly sold as enterprise software.

AI agents. A model looks at the page, as text, as a screenshot or both, decides the next step, takes it and checks the result. Open-source libraries like Browser Use, computer-use models from the major labs and personal agents like OpenClaw all work this way. See what is a computer-use agent? for how.

Side by side

ScriptsRPAAI agents
Speed per runSecondsSeconds to minutesMinutes
Cost per runAlmost nothingLicence plus computeModel usage, from cents to dollars
Same result every timeYesYesNot guaranteed
When the page changesBreaks until fixedBreaks until fixedUsually adapts
A site it's never seenNeeds new codeNeeds a new flowCan try straight away
SetupDeveloper writes codeAnalyst builds a flowYou describe the task
Best forTesting, high-volume repeatsEnterprise processes with audit needsVariety, judgement, one-offs

When a script wins

  • Volume. Ten thousand runs a day of the same steps. An agent would be slow and expensive at that scale.
  • Testing. A test must do exactly the same thing every time, so a failure means the app changed, not the tester.
  • Exactness. Payroll uploads and compliance exports need the same result every run.
  • Speed. A script finishes before an agent has read the page.

When an AI agent wins

  • Variety. Collecting prices from forty supplier sites, each laid out differently. Forty scripts is a project; one agent is a prompt.
  • The long tail. Tasks you'll do once or twice, where writing a script would take longer than doing it by hand.
  • Messy pages. Forms that change, pop-ups, cookie banners, multi-step flows that differ each time.
  • Judgement. “Pick the cheapest option that ships by Friday” or “skip listings that look like duplicates”.
  • Sites that change often, where scripts spend more time broken than working.

Where RPA fits

RPA's strength isn't the clicking; it's the control around it: who can run what, logs of every step, approvals, and connectors to enterprise systems. If you're in a large company with an RPA team, the practical path is usually adding AI steps to existing flows, which the major RPA vendors now support, rather than replacing them.

For small teams and individuals, RPA is usually more than you need. A script or an agent on its own computer covers the same ground for a fraction of the cost.

The best of both: let the agent write the script

The most useful pattern combines them. The agent does the slow, adaptable part once; a script does the fast, repeatable part forever after:

  1. The agent explores. It works through the task on the real site, figuring out the steps.
  2. The agent writes a script that does the same steps, and runs it to check it works.
  3. The script runs on a schedule, fast and nearly free.
  4. When the script breaks, the agent is called in to look at the page, fix the script and run it again.

“Go to the supplier portal (you're already signed in), download last month's invoices as PDFs and save them in ~/invoices/YYYY-MM. Once that works, write a Playwright script in ~/scripts/invoices.ts that does the same thing without you, run it to check it works, and tell me how to schedule it.”

Coding agents like Claude Code, Codex and OpenCode are good at the script-writing half. See Claude Code vs Codex vs OpenCode.

Making agent automation reliable

  • Narrow tasks. “Download last month's invoices” beats “handle my supplier admin”.
  • Structured output. Ask for a CSV or JSON with fixed columns, so mistakes are easy to spot.
  • A check step. Have it confirm the result: the file exists, the row count matches, the total adds up.
  • A real browser that stays signed in, so it isn't fighting a login on every run.
  • A human for the hard bits. Sign-ins, two-factor codes and human checks are faster for you. See human in the loop for AI agents.
  • Respect the site. Follow its terms, use its API where one exists, and don't hammer it with requests.

Where to run browser automation

Scripts run happily in a headless browser on any server. AI agents do better with a real browser on a real desktop: pages render as they do for people, logins stick, and you can watch what went wrong.

A Cubicles computer has both: a full Ubuntu desktop with Chrome and Firefox for the agent, and Python, Node.js and a terminal for the scripts it writes. OpenClaw, Hermes, Claude Code and Codex come installed, and it stays on so schedules run. Your first computer is free. Sign up to try the agent-writes-the-script pattern on a task of your own.

Frequently asked questions

Will AI agents replace Playwright and Selenium?

Not for testing or high-volume repeats, where exact and cheap runs matter. Agents are taking over the long tail of varied, one-off tasks, and increasingly write and fix Playwright scripts themselves.

Is AI browser automation reliable?

Less predictable than a script, but much better at pages it hasn't seen and pages that change. Narrow tasks, structured output, a check step and a person for sign-ins make it reliable enough for most admin work.

Is RPA still worth it?

In large companies with existing RPA teams and audit needs, yes, often with AI steps added. For small teams, scripts and AI agents usually cover the same jobs for far less.

Can an AI agent write Playwright scripts?

Yes. Coding agents like Claude Code, Codex and OpenCode can explore a site, write a Playwright script that repeats the steps, run it to test it, and fix it when the site changes.

What is Browser Use?

Browser Use is an open-source library that lets an AI model control a web browser to complete tasks. It's one of several ways to build a browser agent, and it runs on a Cubicles computer.

Give your agent a computer