Power Your Software Testing with AI Agents and Cloud
The Native AI-Agentic Cloud Platform to Supercharge Quality Engineering. Test Intelligently and Ship Faster.
- TestMu AI (Formerly LambdaTest)
- /
- Blog
- /
- Why AI Agents Fail at End-to-End (E2E) Testing: 12 Limits and the Fix
Why AI Agents Fail at End-to-End (E2E) Testing: 12 Limits and the Fix
Cursor and Playwright MCP write E2E tests fast, then they flake, fake auth and test the code instead of the product. 12 failure modes and the fix.
Published on:
On This Page
- 12 Ways Agents Break E2E
- 1. Can't Get Past Login
- 2. Every Suite Fakes the World
- 3. Mocks That Lie
- 4. Tests Describe the Code
- 5. Selectors That Rot
- 6. Hand-Tuned Waits
- 7. Green Alone, Red Together
- 8. Paying the Model Every Run
- 9. Happy-Path Tunnel Vision
- 10. Red Build Tells Nothing
- 11. "Trust Me, It Passed"
- 12. Fixing the Test, Not the Bug
- Why AI Testing Tools Fail
- The Fix
- Hands-On With Kane CLI
- Playwright MCP vs Kane CLI
- Sources
AI coding agents fail at end-to-end testing because they write E2E tests the way they write code: fast, plausible, and tied to whatever the implementation happens to be today. Unit tests forgive that. E2E tests don't, because an E2E test is only worth something if it encodes what the product should do. It also has to survive the next refactor, and keep running across hundreds of builds without a human reading every red result.
Cursor, Claude Code, and Playwright MCP are very good at the first hour of E2E testing. They open a browser, click through a flow, and emit a Playwright spec. The trouble starts on day two: the login breaks, the mocks disagree, and the suite turns flaky. Then someone shelves the whole thing.
That isn't a guess. In a Cursor forum thread, a developer described trying GPT-5 (thinking) and Claude 4 Sonnet (with and without any thinking) on an internal admin app. The results were tests that couldn't get past login, suites that each faked auth differently, and shared mocks that fixed one failure but caused another. Every suite passed on its own and failed together. He shelved the E2E suite.
The fix is not a better prompt. It's a different architecture: the model decides how to reach an outcome once, a deterministic replay runs it from then on, and the model comes back only when the product has actually changed. You write what must be true; the model never gets a vote on whether it is. Below are the 12 ways the current approach breaks, why each one happens, and how Kane CLI is built around them.
Who this is for: developers and SDETs who already use Cursor, Claude Code, Codex, or Gemini CLI to write code and have tried, or are about to try, letting the same agent own their E2E suite.
TL;DR
AI coding agents fail at end-to-end (E2E) testing because they write E2E tests like code: tied to today's implementation, not to what the product should do. AI E2E testing holds up when the model plans a path once, a deterministic replay runs it, and human-written acceptance criteria decide pass or fail.
Why Are AI-Generated E2E Tests Flaky?
- Frozen selectors: A Cursor or Claude Code Playwright spec freezes today's DOM into
getByTestIdand CSS selectors, so a renamed class or a moved button turns the build red while nothing is broken for the user. - Hand-tuned waits: Agents reach for manual timeouts such as
waitForTimeoutinstead of Playwright's auto-waiting, a common source of flaky tests in AI test automation. - Shared state: Suites that pass alone fail together because of leaked state, order dependence, and shared test data, which no single generation step can see.
Is Playwright MCP Enough for E2E Testing?
- Playwright MCP Cursor workflows: No. Playwright MCP is excellent for letting an agent explore and debug a live browser, but a spec exported from it inherits selector rot, and an agent driving it on every run costs tokens and isn't deterministic.
Does Kane CLI Use an LLM on Every Test Run?
- Author, replay, heal: No. Kane CLI, the agentic testing tool from TestMu AI, works out the path once, then replays it deterministically without an LLM in a few seconds in CI. The model comes back only when the UI has actually moved.
- Self-healing test automation: Kane CLI's healing changes how a test gets there, never what counts as passing. Step-heal re-finds one moved element, flow-heal re-plans the route as a last resort, and a real bug still fails.
The 12 Ways AI Agents Break End-to-End Testing
Every item below comes from developers who tried it, not from a vendor checklist. Each one says what you see, why it happens, and what actually fixes it.
1. The Test Can't Get Past Login
What you see: the agent writes a beautiful checkout test that never reaches checkout. It times out on the sign-in page, or burns tokens hunting for the auth file and base URL every session.
Why: authentication is shared state across the whole suite, and agents reason one file at a time. A developer who built an MCP server to patch this in Playwright MCP named login as problem number one.
Fix: auth belongs to the test run, set once, not reinvented inside every spec.
2. Every Suite Fakes the World Differently
What you see: one suite seeds fake auth data, another logs in for real, a third mocks the routes its own way. Each is internally consistent; together they contradict each other.
Why: an LLM optimizes the file in front of it. Nothing in the loop enforces one testing strategy across the app.
Fix: fewer fakes. A black-box test that drives the real app through the real UI has nothing to disagree with.
3. Mocks That Make the Test Pass and the Product Fail
What you see: shared route mocks fix one failure and cause another. The suite goes green while production breaks, because the test exercised your fake API, not the real one.
Why: the agent is rewarded for green, and a mock is the cheapest way to get green.
Fix: test the outcome the user sees on a real browser against a real environment. Mock only what you truly can't reach.
4. The Test Describes the Code, Not the Requirement
What you see: the agent writes an assertion that corresponds to what the code currently does, including the bug. As one Cursor forum member put it, it is "obsessed with writing tests to match the code."
Why: the code is in context, and the requirement usually isn't. That original poster's own fix was a rule: "There is passing, and there is passing CORRECTLY."
Fix: the requirement must be the test. Acceptance criteria written in plain language, by a human, separate from the implementation.
5. Selectors That Rot on the Next Refactor
What you see: a renamed class, a regenerated id or a moved button turns the build red. Nothing is broken for the user.
Why: a generated Playwright spec freezes today's DOM into getByTestId and CSS selectors. Playwright MCP also reads the accessibility tree, so on HTML that isn't clean and semantic, its locators often fail outright.
Fix: find elements by what they are and what they do, not where they sat yesterday.
6. Hand-Tuned Waits That Guess Wrong
What you see: waitForTimeout(3000) sprinkled through the spec. It passes on a fast laptop and flakes in CI.
Why: agents write non-idiomatic Playwright, reaching for manual timeouts instead of the framework's auto-waiting. That's a common source of flaky tests.
Fix: no hand-written waits at all. The runner waits for the state the step needs.
7. Green Alone, Red Together
What you see: each suite passes in isolation. Run them together, and they fail. This is the exact symptom that made the forum poster shelve his suite.
Why: leaked state, order dependence, and shared test data. These are whole-suite properties no single generation step can see.
Fix: independent tests with their own setup, run in parallel so ordering bugs surface on day one, not month three.
8. Paying the Model on Every Single Run
What you see: an "agentic" test that re-reasons the whole flow each time. It's slower than a script, costs tokens per run, and can take a different path on Tuesday than on Monday.
Why: if the model drives every run, every run is probabilistic. Slack Engineering measured about 40 turns and 3.8M tokens for an MCP-driven flow, and $15-30 per agentic run.
Fix: pay for intelligence once, then replay deterministically. (Section 4 shows how.)
9. Happy-Path Tunnel Vision
What you see: tests for valid card numbers, none for the double charge on a payment timeout, the second user editing the same record, or the permission edge case.
Why: the obvious path is the most likely completion. Edge cases arise from someone asking, "What could go wrong for the business here?"
Fix: a human states the risky outcomes as intents. An agent hunts for bugs beyond the stated path and reports them separately, without silently widening the test.
10. A Red Build That Tells You Nothing
What you see: CI fails. Is checkout broken, or did a cookie banner shift a button? Someone spends an hour finding out, every time.
Why: a script can only say "step 14 failed". It can't distinguish between a broken product and a moved element.
Fix: a verdict with a reason and a category, so red means the product broke, not that something moved.
11. "Trust Me, It Passed"
What you see: the agent reports success. You have its summary, maybe a screenshot, and no way to reconstruct what it actually did.
Why: chat output is not a record. For regulated teams especially, a verdict without evidence is AI-generated confidence.
Fix: every run emits a self-contained, tamper-evident record: steps, screenshots, network, console.
12. The Agent "Fixes" the Test Instead of the Bug
What you see: a test fails, you ask the agent to make CI green, and it loosens the assertion. Now the test checks something else.
Why: to an agent with write access, the test is just more code. Nothing separates the path from the pass criteria.
Fix: healing may change how the test gets there, never what counts as passing. A wrong total should be reported as a bug, not healed into green.
Why AI Testing Tools Fail: One Model Doing Two Jobs That Must Stay Apart
Every E2E test does two different jobs. It finds a path through the UI to a state and judges whether that state is correct. The path should adapt when the UI moves. The judgment must never adapt. Most of the 12 failures stem from tooling that blurs the line between these two jobs.
Today's AI testing setups fall into two camps, and each gets one job wrong:
| Approach | Path (how to get there) | Verdict (did it pass) | What breaks |
|---|---|---|---|
| Agent writes a Playwright spec (Cursor or Claude Code + Playwright MCP, then export) | Frozen into selectors and waits on the day it was written | Deterministic assertions, but written to match the code | Selector rot, flaky waits, tests that describe the bug (failures 4-7) |
| Agent drives the browser on every run (MCP-style agentic test) | Re-reasoned live, every run | Partly the model's own judgment | Token cost per run, different behavior run to run, "trust me it passed", fixing the test instead of the bug (8, 11, 12) |
| Kane CLI: author once, replay, heal on change | Worked out once by the model, then replayed deterministically; repaired only when the UI actually moved | Your acceptance criteria, checked deterministically; the model has no vote | Strongest when an element's address changes but its meaning doesn't (see honest limits below) |
The compressed version: probabilistic execution, deterministic validation. Let intelligence find the route. Never let it decide whether you arrived.
This is also why "just write better agent rules" helps only so much. Rules shape what the model writes on the first day. They do nothing to stop a frozen selector from rotting on day 30, and they don't stop a live agent from grading its own homework on day 31.
The Fix for AI Test Automation: Author Once, Replay Deterministically, Heal Only When the UI Moved
Kane CLI does not re-decide the test on every run. A test lives in one of three states, and the model is involved in only one and a half of them.

Kane CLI run lifecycle · author, replay, heal
- Author. You state the outcome in plain English. The model works out how to reach it in a real browser: full intelligence, full cost, once.
- Replay. From then on, the run is deterministic and cached. There's no LLM in the loop; it takes a few seconds and runs in CI. This is the overwhelming majority of runs.
- Heal. Intelligence comes back only when replay can't find its target. That's not on a schedule and not on every run, only when the UI has actually moved.
Healing has two tiers, and the difference is the entire safety story:
- Step-heal is the common case. One step's target can't be resolved because an ID was regenerated, an element moved, or the markup was refactored. Kane re-finds that one element by what it is rather than where it sat. Every other step stays untouched. We pointed a saved check at a page built to regenerate its element IDs on every single load; it re-found its target and passed every time, with no edit, no engineer, and no LLM spend.
- Flow-heal runs only when a step is no longer possible at all, because the route itself changed. Only then does anything re-plan the path to the objective.
Neither tier can touch the acceptance criteria. Healing can find a new route to the same stated outcome. It has no authority to revise the meaning of "passed". A wrong order total doesn't get healed into green; it gets reported as a bug. Reasoning owns the path; verification owns the verdict.
How That Maps to the 12 Failures
| # | Failure | What Kane CLI does instead |
|---|---|---|
| 1 | Can't get past login | Sign-in is just part of the plain-English outcome, worked out once and then replayed, not rediscovered every session |
| 2 | Every suite fakes the world differently | One way to write a test: a plain-English outcome against the real app |
| 3 | Mocks that lie | Drives a real browser against a real environment; nothing to mock |
| 4 | Test describes the code | You write the acceptance criteria; the model never writes or edits the verdict |
| 5 | Selector rot | No selectors to write; step-heal re-finds moved elements |
| 6 | Flaky waits | No hand-tuned waits to guess wrong |
| 7 | Green alone, red together | Each test is independent; testrun run --parallel N surfaces ordering bugs early |
| 8 | Paying the model every run | Replay has no LLM; you pay for intelligence at author and heal time only |
| 9 | Happy-path tunnel vision | --bug-detection continues to report issues off the stated path without widening the test |
| 10 | Red build tells you nothing | run_end carries status, one_liner, and reason; exit codes 0 pass, 1 fail, 2 setup error, 3 timeout |
| 11 | "Trust me, it passed" | Every run emits a sha256-hashed .evidence pack you can replay step by step |
| 12 | Agent fixes the test, not the bug | Healing is scoped to the path; criteria are out of its reach |
Hands-On: E2E Testing With Kane CLI Inside Cursor or Claude Code
You keep your coding agent. Kane CLI becomes the thing it calls when it needs to know whether the product actually works. Setup takes about five minutes.
1. Install the CLI and the Agent Skill
npm install -g @testmuai/kane-cli
npx @testmuai/kane-cli-skill # teaches Claude Code, Codex or Gemini CLI how to call Kane2. Authenticate Non-Interactively
Agents have no TTY, so log in with flags rather than a prompt:
kane-cli login --username "$LT_USERNAME" --access-key "$LT_ACCESS_KEY"3. State an Outcome, Not a Script
kane-cli run "Sign in as a returning customer, add the blue hoodie in size M to the cart, \
check out with the saved card, and confirm the order total equals the cart total" \
--url https://staging.yourapp.com \
--agent --headless --timeout 300 --max-steps 40 \
--final-validation on--agent switches output to NDJSON, so the coding agent reads machine output instead of scraping terminal text. --final-validation on adds a final check of the end state against your stated outcome.
4. Let the Agent Read the Verdict, Not Guess It
The process exits 0 on pass, 1 on fail, 2 on a setup error, and 3 on a timeout, so CI and agents can branch without parsing prose. The last NDJSON line is the run_end event, which carries:
statusandone_liner: the verdict in a sentencereason: why it failed, in terms of your outcomefinal_state: where the browser ended uptest_urlandrun_dir: where the evidence livestoken_usage: what the run cost
That closes the loop the forum poster couldn't: the agent changes code, runs Kane, reads reason, fixes, and reruns until it exits 0. It never rewrites the acceptance criteria to get there.
5. Add One Rule to Your Agent Instructions
Paste this into CLAUDE.md, AGENTS.md or .cursor/rules:
## End-to-end verification
- Never write Playwright or Cypress specs by hand for user flows.
- After any change that touches a user-facing flow, run:
kane-cli run "<the outcome in plain English>" --url $STAGING_URL --agent --headless
- Treat exit code 1 as a product bug. Fix the code, never the outcome sentence.
- Treat exit code 2 or 3 as environment problems and report them; do not retry blindly.6. Promote What Matters Into a Committed Suite
Keep important flows as markdown test files in the repo, so the outcome sentences get reviewed in PRs like any other code:
kane-cli testmd run tests/checkout_test.md
kane-cli testrun run --tags smoke --parallel 4 --on-failure fail-fastNeed scale? kane-cli plugin install remote-execution, then kane-cli testrun run --remote --parallel 20 fans out on HyperExecute (this needs a HyperExecute macOS runners plan).
7. Hunt Bugs Beyond the Stated Path
kane-cli run "Complete checkout with a saved card" --url $STAGING_URL \
--agent --bug-detection continueThe run still answers your outcome. Issues it notices along the way are reported separately, with a category and a confidence signal, rather than quietly expanding what the test checks.
8. Keep an Exit to Plain Playwright
If a team wants a script for a particular flow, export it. You're never locked into a format you can't read:
kane-cli run "..." --url $STAGING_URL --code-export --code-language javascript
kane-cli testmd export tests/checkout_test.md --language javascript9. Audit Any Verdict
Every run writes a sha256-hashed .evidence pack. Drop it into evidence.lambdatest.com to replay the run step by step, with screenshots, network logs, console logs, and terminal output. On a failure, you also get the bug Kane reported, its category, and the verdict behind it. If you can't get from a verdict back to what produced it, that's a bug in Kane, not a limitation you should accept.
10. Mobile, Too
The same outcome-first approach runs against native apps on a local Android emulator or iOS Simulator (currently macOS on Apple Silicon):
kane-cli doctor --target emulator --install
kane-cli run "Log in and open order history" --target emulator \
--device-name "Pixel 7" --os-version 14 --app ./app.apkCursor + Playwright MCP vs Kane CLI for E2E Testing
Use Playwright MCP to explore and debug with your agent. Use Kane CLI when the result has to gate a release. The two work side by side; the table shows where each one belongs.
| Cursor or Claude Code + Playwright MCP | Kane CLI | |
|---|---|---|
| What you hand over | A prompt; the agent explores, then writes a spec | One plain-English outcome plus a URL |
| What gets saved | A Playwright file with selectors and waits | The outcome, replayed deterministically |
| Model involvement per CI run | None if you exported a spec; every turn if the agent drives live | None on replay; only at author or heal time |
| When the UI changes | Spec breaks; a human or agent edits code | Step-heal re-finds the element; flow-heal re-plans only if the route changed |
| Who decides pass or fail | Assertions the agent wrote, often matched to current code | Your acceptance criteria; the model has no vote |
| CI signal | Test runner output | Exit codes 0/1/2/3 plus a run_end reason |
| Audit trail | Traces, if configured | sha256-hashed .evidence pack for every run |
| Bugs off the stated path | Only if you prompt for them | --bug-detection continue reports them separately |
| Parallel and cloud | Your own infrastructure | --parallel N locally, --remote on HyperExecute |
| Escape hatch | It's already code | --code-export to Playwright JavaScript |
| Best for | Exploration, debugging, one-off checks | Regression suites that gate a release |
For a fuller breakdown, see our Playwright MCP Guide, Playwright CLI vs Playwright MCP vs Kane CLI, and Agentic Testing in the E2E Stack.
What Kane CLI Does Not Solve (On Purpose, or Not Yet)
A testing tool that claims to fix everything is selling something. Here is where the boundary is.
- Semantic drift is harder than moved elements. Healing is strongest when an element's address changes and its meaning doesn't. If a button keeps its label but now routes somewhere else, Kane would rather fail loudly than adapt. That's a deliberate choice, not a solved problem.
- Flaky software vs flaky tests is only partly solved. Kane removes two of the usual three causes, rotting locators and hand-tuned waits, by construction. For genuinely nondeterministic app state, the bug-detection pass gives a verdict with a confidence signal, not certainty.
- It won't pick your risks for you. Deciding that a double charge on a payment timeout matters more than an error is a product judgment. Kane makes each stated intent cheap to verify forever. The bottleneck becomes how many intents a human is willing to state, which is the part that should stay human.
- It isn't observability. Memory leaks, slow queries, and misconfigured infrastructure don't show up in a UI flow. Keep your monitoring.
- It doesn't replace your governance process. It does give that process something it rarely has: a tamper-evident record of what was tested, how it was tested, and what happened.
Sources
- End-to-End Testing... A tricky area for current-gen LLMs?, Cursor Community Forum, August to December 2025
- Kane CLI product page, TestMu AI
- Slack Engineering: agentic E2E testing data
Author
Srinivasan Sekar is Director of Engineering at TestMu AI (formerly LambdaTest), where he leads engineering and open-source initiatives behind the Selenium and Appium automation grid and owns TestMu AI's MCP Server. A committer to Appium and a contributor to Selenium, WebdriverIO, Taiko, and AppiumTestDistribution, he brings over 15 years of experience in quality engineering and open-source technologies. He is the author of the Apress book 'The MCP Standard: A Developer's Guide to Building Universal AI Tools with the Model Context Protocol,' a Certified Kubernetes and Cloud Native Associate, and an international conference speaker. Before TestMu AI he spent over eight years at Thoughtworks as a Principal Consultant and Quality Architect. Srinivasan holds a B.Tech in Information Technology from Anna University.
Reviewer
Mayank Bhola is Co-Founder and Head of Products at TestMu AI (formerly LambdaTest), where he leads the entire product portfolio across KaneAI, Kane CLI, HyperExecute, SmartUI, the Real Device Cloud, Accessibility, and other software testing product lines. As an early Lead Architect he designed and built the company's flagship Tunnel technology from scratch, created the React-based automation platform, and architected the data-intensive pipelines and FAAS services that scale it. He brings more than 10 years of experience in software development and product engineering, with earlier roles as Head of Technology at Juggernaut Books and Senior Software Engineer at PressPlay TV and Zomato. Mayank holds a B.Tech in Computer Engineering from JIIT Noida.
AI Agent E2E Testing FAQs
Did you find this page helpful?
More Related Blogs
TestMu AI forEnterprise
Get access to solutions built on Enterprise
grade security, privacy, & compliance
- Advanced access controls
- Advanced data retention rules
- Advanced Local Testing
- Premium Support options
- Early access to beta features
- Private Slack Channel
- Unlimited Manual Accessibility DevTools Tests



