Commonshell

Research · Paper 1 of the testing series

Token cost of agent-driven UI testing: interactive browser execution versus executable Selenium IDE scripts

Commonshell research paper · 24 November 2026 · one form, one model, small sample (see Threats to validity)

PDF Per-run token data (TSV) The .side script The 13 test cases

Abstract

We compared two ways a coding agent can test a web UI. Both used the same 13 manual test cases for a 3-step, 15-field sign-up form with cross-field validation:

Every valid run passed all 13 cases. The costs, in input-equivalent tokens (cache reads at 0.1×, cache writes at 1.25×, output at 5×), were:

InteractiveScriptScript saving
Authoring (first run)242k95k2.6×
Regression run, agent-supervised204k54k3.8×
Regression run, runner alone—0—

Applied to the run rate measured on one developer's machine (about 1,500 test-case executions a month, 57% of them re-runs), scripts would save 68–82% of testing tokens: 17–21M input-equivalent tokens per developer per month, or 172–207M for a team of 10. Under a conservative fixed-overhead model, the saving is 41–72%. We describe one invalidated run caused by the test runner killing other WebDriver sessions, and the threats to validity of a small-sample study.

1. Introduction

Coding agents increasingly test the web interfaces they build. The common approach is to give the agent a browser tool (in the style of Playwright MCP or computer-use tools): the agent performs one action per tool call (open, fill, select, click) and receives a snapshot of the page after each action, which it reads to decide whether the expected result holds. We call this interactive execution. Every action costs a model round trip, and every snapshot is input tokens. The cost recurs in full every time the tests are run again.

An alternative is for the agent to write the test cases down as an executable script, here a Selenium IDE .side file. A runner then executes the script without the model. The agent spends tokens to write and check the script once. After that, a regression run costs one tool call and a pass/fail summary.

This note measures both approaches on the same task: 13 manual test cases for a 3-step, 15-field sign-up form with cross-field validation. It reports tokens, tool calls and wall-clock time for the first run (authoring) and for later regression runs. Our question is practical: when is it worth having the agent write the script, and by how much?

2. Method

2.1 System under test

The page is a single static HTML page (8.6 KB, no framework), served on 127.0.0.1:4391 and titled "Sign up: Acme Cloud". It has three steps:

That makes 15 fields. Next validates the current step. Back keeps the values already entered. Create account validates step 3 and shows a summary. Each field's error appears in #err-<id>.

The cross-field rules are:

2.2 Test cases

There are 13 manual test cases (TC-1 to TC-13), written in plain language with numbered steps and expected results (tests/commonshell/signup-form.md). Both arms received the same cases:

Each case starts from a fresh page and fills in any earlier steps it needs.

2.3 Arms

A. Interactive execution. The agent drives headless Chrome through a command-line browser tool (tools/bt.py, raw WebDriver over chromedriver 158, with a temporary profile). It has start, open, snapshot, fill, select, click and stop. Every action prints a compact page snapshot afterwards: headings, the current step, fields with their values and invalid state, visible errors and buttons. This is the observation a Playwright-style tool returns. The agent was told to use one tool call per browser action and not to chain actions in scripts.

B. Executable script. The agent follows a write-then-check workflow:

  1. Write each manual case as one test in a scratch .side file.
  2. Run it with Commonshell's runner (cs test --side … --no-visual --no-reflect) and fix the test until it matches the page.
  3. Append the checked test to tests/commonshell/signup-form.side.
  4. Finally, run the whole file.

The runner executes in its own headless Chrome and prints one line per command with ok or FAILED.

Regression runs. After authoring, each arm was run again on the unchanged page by a fresh agent with no memory of the first run:

2.4 Agents and measurement

Every run is a fresh general-purpose sub-agent of the same model (the session's default sub-agent model) with a short task prompt (paper/prompts.md), and none sees another's context. We record the harness's own per-agent report:

No arm was told what the other arm does. Both were told not to edit the page or the test cases.

We also timed the runner on its own, with no agent: one cs test invocation of the saved file, which uses no model tokens.

Input-equivalent tokens. Prompt caching makes raw token counts misleading. A cache read is billed at a tenth of an uncached input token, so we also report a weighted figure using Anthropic's published price ratios: uncached input ×1, cache write ×1.25, cache read ×0.1, output ×5. The harness's own per-agent "tokens" figure tracks each agent's peak context, not its total consumption, so we computed totals from the per-turn usage records in each agent's transcript.

3. Results

3.1 Correctness

Every valid run, authoring and regression, in both arms, reported 13 of 13 cases passing, and none found a defect in the form. The script arm also checked that its assertions can fail: it ran a copy of TC-10 with a wrong expected message, and that copy failed as it should. Two of the three interactive agents (A1, A2) also reported a minor usability issue that no test case covers: an error stays on screen after the field is fixed, until the next Next or Create account click. No script-arm agent reported it.

3.2 Cost per run

Table 1 reports every run. Billed input is uncached input plus cache writes plus cache reads.

RunArmPhaseTool callsModel turnsWall time (s)Billed inputOutputInput-equivalentPeak context
A1InteractiveAuthoring82281581,236,79811,628241.9k59.7k
A2InteractiveRegression 169301431,099,9509,822198.1k47.3k
A3InteractiveRegression 273251311,033,54410,081210.3k56.7k
B1ScriptAuthoring78147277,8155,86594.8k40.3k
B2ScriptRegression 15660176,2731,75458.2k35.1k
B3ScriptRegression 24556156,5231,47549.3k36.3k
RRunner onlyRegression10160000
A0InteractiveAuthoring, invalid41295501,151,2538,090—53.4k

Table 1. Per-run usage. A0 was invalidated (§3.5) and is excluded from all averages.

Table 2 summarises the two arms.

InteractiveScriptRatio
Authoring, billed input1.24M0.28M4.5×
Authoring, input-equivalent242k95k2.6×
Regression mean, billed input1.07M0.17M6.4×
Regression mean, input-equivalent204k54k3.8×
Regression mean, output tokens9.95k1.61k6.2×
Regression mean, tool calls714.516×
Regression mean, wall time137 s58 s (16 s for the runner alone)2.4× (8.6×)

Table 2. Arm means.

The fixed cost of starting an agent explains most of the script arm's regression cost. Its peak context of about 35k tokens is mostly the system prompt and tool definitions: the cache writes in B2 and B3 were 23–28k tokens, for only 4–5 tool calls. The test content itself is small. The runner's pass/fail lines are under 1 KB, and its full log is about 19 KB.

3.3 Cumulative cost

The interactive arm has no artifact to reuse, so its cost recurs on every run. Table 3 extends the means to N regression runs after authoring, in input-equivalent tokens.

Regression runs NInteractiveScript, agent-supervisedScript, runner aloneInteractive ÷ supervised script
0 (authoring only)242k95k95k2.6×
1446k149k95k3.0×
102.28M633k95k3.6×
5010.45M2.78M95k3.8×

Table 3. Projected cumulative input-equivalent tokens: authoring + N × regression mean.

The script arm is cheaper at every N, including N = 0. As N grows, the ratio between the two agent-driven arms tends to the per-run ratio of 3.8×. The runner-alone column shows the limit. When the runner is wired into CI or a hook that only calls the agent on a failure, regression runs cost no model tokens at all.

3.4 Process observations

3.5 Invalidated run

The first interactive authoring run (A0) ran at the same time as the script authoring run (B1). The interactive agent's chromedriver kept dying about 5 seconds after each start, and A0 completed only TC-1 to TC-3. Afterwards we reproduced the cause: a single cs test run terminated a chromedriver that was running independently on another port. Commonshell's runner cleans up chromedriver processes it did not start. All later runs ran one at a time. A0 is reported in Table 1 for completeness only. It spent 1.15M billed input tokens without producing a usable result, a cost of fragile interactive tooling that a single-command runner does not risk in the same way.

4. Discussion

The difference comes from where the page observations go. In interactive execution, every action returns a page snapshot that becomes part of the agent's context and is re-read on every later turn. Prompt caching softens this but does not remove it: cache reads were over 95% of the interactive arm's billed input. In the script arm, the runner consumes the observations and returns only a verdict. The agent's context grows with the number of tests, not the number of actions: 240 recorded commands produced about 1 KB of summary.

Authoring costs the script arm something extra, because it has to write and debug JSON. Even so, it cost less than interactive execution of the same cases. The interactive arm needed 82 tool calls to perform 13 cases, while the script arm needed 7 to author and run all of them.

The interactive arm is not without merit. Its agents looked at the page after every action, so they noticed things outside the expected results. Two of the three interactive runs reported the stale-error usability issue (§3.1), and no script-arm agent did. That is a real advantage: a script only checks what it was told to check. For exploratory testing, interactive execution remains the natural tool. For tests that will be run more than once, the measurements favour writing them down.

5. Projected monthly savings for a team

5.1 How often the tool is run

We have no team-wide counts. Commonshell's usage counting started on 2026-11-22, it sends no per-user IDs, and it does not record individual test runs. We therefore measured the run rate of one developer's machine from its own run history (cs runs, 2026-11-17 to 2026-11-24), excluding this study's runs:

MeasureValue
Test-case executions428
Active days6 (of 8 calendar days)
Executions per active day71.3
Runner invocations118 (3.6 test cases each)
Distinct tests182 (2.35 runs each)
First runs / re-runs43% / 57%
Failure rate15.4%

Table 4. Observed test activity on one developer's machine.

This developer was building a testing product and worked with agents all day, so the rate is high. We report two scenarios:

5.2 Per-case cost

We divided each run in Table 1 by its 13 cases. In input-equivalent tokens, one test case cost:

InteractiveScript, agent-supervisedScript, runner only
First run (authoring)18.6k7.3k7.3k
Re-run15.7k4.1k0
Raw tokens, first run / re-run96.0k / 82.8k21.8k / 12.9k21.8k / 0
Time, first run / re-run12.1 s / 10.5 s11.3 s / 4.5 s11.3 s / 1.2 s

Table 5. Per-case cost derived from Table 1.

5.3 Monthly totals

Monthly cost = first runs × first-run cost + re-runs × re-run cost (paper/monthly.py):

Team sizeInteractiveScript, agent-supervisedSavingScript + runnerSavingAgent hours: interactive / supervised / runner
125.4M8.2M17.2M (68%)4.6M20.7M (82%)4.7 / 3.1 / 2.3
5127M41M86M (68%)23M104M (82%)23 / 15 / 11
10254M82M172M (68%)46M207M (82%)47 / 31 / 23
25634M205M429M (68%)116M518M (82%)117 / 77 / 57

Table 6. Observed scenario, input-equivalent tokens per month. In raw tokens, a team of 10 would use 1.33B (interactive), 0.25B (supervised script) or 0.14B (script + runner) per month.

In the typical scenario, every figure in Table 6 scales by 0.25. A team of 10 would save about 43M input-equivalent tokens a month with supervised scripts, or 52M with the runner doing re-runs, and about 4–6 agent-hours.

5.4 Conservative bound

Table 6 scales costs from 13-case runs. Real invocations are smaller (3.6 cases on average), and if each one starts a fresh agent, that agent's fixed start-up cost is spread over fewer cases. We measured this fixed cost as 53.8k input-equivalent tokens, which is essentially the whole of a script regression run. Per-case marginal costs are then:

Interactive, first runInteractive, re-runScript, first runScript, re-run
14.5k11.6k3.2k≈0

This gives 413 invocations per developer per month in the observed scenario, and these per-developer costs:

InteractiveScript, agent-supervisedScript + runner
Per developer per month41.4M24.2M11.5M
Saving vs interactive—41%72%
Team of 10, saving—172M299M

In the runner column, an agent is involved only in invocations that author tests. So even under this bound, scripts save between two-fifths and nearly three-quarters of the tokens. The saving grows with the number of cases per run.

5.5 Reading the numbers

6. Threats to validity

7. Conclusion

Every valid run in both arms passed all 13 test cases. For a 13-case, 3-step form test, having the agent write a .side file and replay it cost:

It was also faster per regression run and kept each test independent. At the run rate measured on one developer's machine, this means 68–82% fewer testing tokens each month (41–72% in the conservative model). For a team of 10, that is 172–207M input-equivalent tokens and 16–24 agent-hours a month. The script approach paid for itself on the first run. Our recommendation for agent workflows is:

  1. Use interactive execution to explore.
  2. Turn checked manual cases into an executable script as soon as they are settled.
  3. Let the runner, not the model, carry the repeated runs.

Appendix A. Artifacts

Environment: macOS 26.7.3, Google Chrome 158.0.8127.88, chromedriver 158, Commonshell cs 0.1.0.

Appendix B. Incidental findings

  1. Commonshell's cs test terminates chromedriver processes it did not start (§3.5). It should track and stop only its own drivers.
  2. The runner does not support assertVisible or assertNotVisible. waitForElementVisible and waitForElementNotVisible work instead.
  3. Sometimes the runner prints a stray kill: NNN: No such process line before its result.
  4. In tools/bt.py, fill does not recognise date inputs, so it falls back to key presses, which Chrome reads in month/day/year order. The root cause is not confirmed.