AI changed how teams write tests, but it did not eliminate the old tradeoffs. If anything, it made them easier to ignore for a while and more expensive later. A test suite still has to survive selector churn, timing issues, browser differences, CI instability, and the organizational cost of maintaining a framework that only a few people understand.

That is why the question of Selenium versus Playwright looks different in 2026 than it did a few years ago. Both tools can be productive. Both can be used with AI coding assistants. Both can generate a lot of test code quickly. But once you factor in agentic workflows, MCP-style tool integration, and AI-generated tests, the real comparison becomes less about syntax and more about lifecycle cost, reliability, and who on your team can keep the suite healthy.

This article looks at Selenium vs Playwright with AI from a practical angle: maintenance, token usage, infrastructure, test reliability, and total cost. It also explains where a platform like Endtest fits for teams that want AI-assisted automation without owning either framework or its surrounding infrastructure.

What AI actually changed in Test automation

AI did not make browser automation magically stable. It changed the economics of creation and maintenance.

Before coding assistants, writing a test often meant manually coding every selector, wait, assertion, and helper function. Now, a developer can ask an LLM to draft a Playwright or Selenium test in minutes. In some teams, an agent can also inspect a repository, infer page objects, and produce a whole scaffold with fixtures and assertions.

That sounds like a huge productivity gain, and it is, but only for the first draft. The harder part is everything that happens after the test lands in CI:

  • locators drift when UI components change
  • timing assumptions break when data or rendering changes
  • flaky waits trigger reruns
  • browser setup and runtime dependencies accumulate
  • the test code becomes another codebase that needs reviews, refactors, and upgrades

AI reduces the cost of writing tests, but not the cost of being responsible for them.

That distinction matters because many teams now have more test code than they can sustainably maintain. AI makes it easier to create fragile automation faster, which means the bottleneck moves from authoring to stewardship.

Selenium and Playwright are solving different parts of the problem

Selenium and Playwright are both browser automation frameworks, but they were designed in different eras and for different assumptions.

Selenium: broad compatibility, mature ecosystem, more moving parts

Selenium is the older and broader standard for browser automation. It has a very large ecosystem, broad language support, and the longest track record in enterprise automation. It is also deeply integrated into a lot of existing QA infrastructure and vendor tooling.

That breadth comes with costs. In practice, Selenium teams often manage:

  • browser drivers or grid infrastructure
  • implicit and explicit waits carefully tuned per app
  • language-specific test harnesses and page object layers
  • more boilerplate around setup and teardown
  • more manual handling of flaky locators and stale element references

For long-lived enterprise systems, this can be acceptable. For new teams, it often feels heavy unless there is already a strong reason to use it.

Playwright: modern ergonomics, better default reliability, still a codebase

Playwright is newer and usually easier to start with. It offers a modern API, auto-waiting, strong browser context isolation, and a developer experience that feels closer to writing application code than old-school test harnesses.

In many greenfield projects, Playwright is the better default because it reduces ceremony and handles many timing issues more gracefully.

But Playwright is still code. That means:

  • someone owns the repository
  • someone manages refactors when the app changes
  • someone keeps fixtures and helpers clean
  • someone decides how to structure test data and selectors
  • someone monitors CI runtime and parallelization costs

So while Playwright often lowers the friction of automation, it does not remove the ownership burden.

AI coding assistants changed how teams build both

A lot of the current debate comes from teams using Copilot, ChatGPT, Claude, or internal agents to generate framework code. That can work well, especially for repetitive tasks.

For example, an agent can draft a Playwright login flow like this:

import { test, expect } from '@playwright/test';
test('user can sign in', async ({ page }) => {
  await page.goto('https://example.com/login');
  await page.getByLabel('Email').fill('user@example.com');
  await page.getByLabel('Password').fill('secret123');
  await page.getByRole('button', { name: 'Sign in' }).click();
  await expect(page.getByText('Welcome back')).toBeVisible();
});

Or a Selenium flow in Python:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

browser = webdriver.Chrome() wait = WebDriverWait(browser, 10)

browser.get(‘https://example.com/login’) browser.find_element(By.ID, ‘email’).send_keys(‘user@example.com’) browser.find_element(By.ID, ‘password’).send_keys(‘secret123’) browser.find_element(By.CSS_SELECTOR, ‘button[type=”submit”]’).click() wait.until(EC.visibility_of_element_located((By.XPATH, “//*[text()=’Welcome back’]”)))

The problem is not that the code is impossible to generate. The problem is that generated code tends to inherit whatever assumptions the model made about the app, selectors, and timing. The more complex the app, the more likely the generated test needs human intervention.

AI can draft test code, but it does not automatically solve:

  • locator stability
  • cross-browser behavior
  • environment-specific failures
  • test data provisioning
  • maintenance after UI change

That is especially true when the output is code that must live in the same repository as application source, under the same CI pressure.

Maintenance is the main difference, not syntax

If you are comparing Selenium and Playwright in the AI era, maintenance is the axis that matters most.

Selenium maintenance profile

Selenium maintenance usually grows around shared utilities, driver management, and locator discipline. Teams spend time on:

  • keeping drivers and browser versions compatible
  • reducing flaky waits and stale references
  • working around framework differences across languages
  • preserving a stable suite architecture as the app evolves

AI can help write these layers, but it cannot eliminate them. In many cases, AI-generated Selenium tests become long, brittle scripts unless a strong automation engineer normalizes them into reusable abstractions.

Playwright maintenance profile

Playwright generally starts with lower friction. Auto-waiting and the modern API reduce a lot of early pain. This is why many teams perceive Playwright as cheaper to maintain.

The catch is that lower friction can increase volume. If creating a new test is easy, teams often create more of them, faster than they can design a maintainable structure. The suite still needs selector strategy, fixture discipline, and refactoring conventions.

In other words, Playwright reduces the cost per test, but not the need for test engineering.

AI-generated tests amplify the maintenance problem

AI-generated tests can be useful for scaffolding, exploratory coverage, and quick gap filling. They are less useful when treated as a replacement for test design.

A generated test often looks complete because it runs once. The hidden issue is whether it remains understandable six months later. If a human cannot quickly see what the test is proving, why a locator was chosen, and how to update it, the test is not cheap, it is deferred debt.

Reliability, flakiness, and why locators still matter

The biggest source of instability in browser automation is still locator quality. AI changes how those locators are produced, but not the underlying problem.

A test that targets a brittle CSS class or a deeply nested XPath will eventually fail when the UI changes. Selenium exposes this pain more directly because the suite often relies on explicit waits and manual locator logic. Playwright hides some of it with better querying and auto-waiting, but it cannot guarantee semantic stability if the selector itself is weak.

This matters because AI-generated tests are often synthesized from the current DOM state. That can be useful, but the DOM is not always the same thing as the user interface. A good test needs selectors that reflect user-visible intent, not just whatever the agent found first.

A practical heuristic

If your automation strategy depends on repeatedly regenerating selectors, you are not really reducing maintenance, you are outsourcing it to the next run.

That is where AI-powered platforms become interesting. Instead of generating code that still needs to be maintained, some platforms generate editable tests with better semantic handling and built-in healing.

Infrastructure and runtime cost are part of the comparison

Teams often compare Selenium and Playwright by developer ergonomics, but infrastructure is where the long-term cost becomes visible.

Selenium infrastructure

Selenium commonly requires more explicit orchestration, especially at scale. Depending on the setup, you may manage:

  • local browser binaries in CI
  • Docker images for test runners
  • Selenium Grid or third-party grid services
  • language-specific dependencies
  • parallel execution coordination

This is workable, but every layer adds operational responsibility.

Playwright infrastructure

Playwright is usually easier to run in CI and provides a more integrated runner experience. Many teams appreciate the simpler setup and stable defaults. Still, a serious suite needs:

  • clean CI images
  • browser cache management
  • parallelism tuning
  • artifact retention for traces and videos
  • environment consistency across developers and pipelines

Playwright reduces setup overhead, but it does not eliminate the need for test infrastructure.

Token usage enters the bill with AI-assisted workflows

AI introduces a new cost bucket that teams often ignore at first, token usage. If your workflow asks an LLM to generate tests, repair tests, review failures, or inspect multiple files, then every test change has a model cost.

That cost can stay modest for small cases, but it can also grow quickly when:

  • prompts include large DOM snapshots
  • agents inspect multiple files before making changes
  • failures are retried with more context
  • many developers use the assistant frequently

This is one reason AI-assisted code generation can be misleading in cost discussions. The first draft may seem cheap because the developer does less typing. The real expense appears in repeated model calls, human review time, and downstream maintenance.

Selenium vs Playwright with AI, where each one fits best

Choose Selenium if you need breadth and legacy alignment

Selenium still makes sense when:

  • you already have a large Selenium estate
  • you need language flexibility across many teams
  • your organization has built a mature execution stack around it
  • vendor or compliance requirements already standardize on it

AI can help with test generation, refactoring, and migration assistance, but it will not change the fact that Selenium is a legacy-compatible framework with corresponding operational weight.

Choose Playwright if you are starting fresh and want a code-first workflow

Playwright is a stronger default when:

  • you are building a new automation suite
  • your engineers are comfortable with TypeScript or modern Python
  • you want strong dev ergonomics and fast feedback
  • you want a cleaner experience around waiting and browser contexts

AI helps Playwright especially well because the framework API is concise and more predictable than older browser libraries.

Choose neither if your team wants AI-assisted testing without framework ownership

This is where a platform approach becomes attractive. If your actual goal is not to maintain browser automation code, but to get reliable coverage faster, then a tool like Endtest changes the equation.

Endtest uses agentic AI to create standard, editable platform-native test steps from plain-English scenarios, rather than generating a codebase your team must own. It also supports importing existing Selenium, Playwright, or Cypress tests, which is useful when you want a transition path instead of a rewrite.

Why Endtest matters in this comparison

For teams evaluating Selenium AI testing or Playwright AI testing, the most important question is whether AI is being used to accelerate code generation or to remove the need for code maintenance altogether.

Endtest is positioned for the second category.

Its Self-Healing Tests capability is relevant because locator drift is the main cause of maintenance burden in browser automation. When a locator no longer resolves, Endtest can inspect surrounding context, pick a new locator, log the change, and continue the run. That is a different maintenance model from Selenium or Playwright, where the burden usually falls back to the test author.

Its AI Test Creation Agent is also practical because generated tests are not hidden behind a prompt or model transcript. They land as editable steps in the Endtest editor, which means teams can review and refine them without maintaining a framework scaffold.

This is the core distinction:

  • Selenium and Playwright, even with AI, are still code-first automation stacks
  • Endtest is a platform-first automation workflow with agentic AI assistance

For many teams, that means less time spent on drivers, runners, and locator repair, and more time spent on actual coverage.

If you are evaluating migration paths, the Endtest vs Selenium and Endtest vs Playwright comparisons are useful starting points, especially if your current suite already has years of framework-specific debt.

If your team keeps asking, “Can AI just fix the test every time the UI changes?”, that is usually a sign you want a healing platform, not another code generator.

A decision matrix that reflects 2026 reality

Here is the simplest practical way to choose.

Selenium is still the right call when

  • you have a large existing investment in Selenium
  • you need maximum ecosystem compatibility
  • your org already has Selenium expertise and infrastructure
  • rewriting would cost more than modernization

Playwright is usually the right call when

  • you are starting a new code-based suite
  • you want cleaner APIs and less boilerplate
  • your team can own a modern TypeScript or Python codebase
  • you care about faster local feedback and easier browser orchestration

Endtest is often the better choice when

  • you want AI-assisted automation without writing and maintaining framework code
  • your team needs business-readable, editable tests
  • flakiness and locator churn dominate maintenance cost
  • you want faster migration from legacy Selenium or Playwright tests into a managed platform

Example: where AI helps, and where it stops helping

Consider a simple checkout regression:

  1. log in
  2. add an item to cart
  3. apply a discount code
  4. verify order total
  5. submit the order

An LLM can draft this test in Selenium or Playwright. It may even choose decent selectors. But if the app changes the discount widget, or the order summary renders asynchronously, the test may fail in CI.

At that point, the maintenance question becomes:

  • do we edit the code and improve waits or selectors?
  • do we prompt the agent to regenerate the test?
  • do we build more abstraction around the page?
  • or do we want a platform that can heal or abstract these changes for us?

That is why the most productive teams do not ask whether AI can write tests. They ask how much they want to own after the test exists.

A realistic recommendation for different teams

Small product teams

If you have a few engineers and need immediate coverage, Playwright is usually the best code-first starting point. It has a strong developer experience and plays well with AI coding assistants.

Enterprise QA organizations

If you already run Selenium at scale, do not underestimate the cost of migration. Use AI to modernize selectively, improve flaky paths, and reduce boilerplate. But if your suite is increasingly costly to maintain, a platform migration should be part of the discussion, not just another framework rewrite.

QA managers and CTOs

Look beyond test writing time. Evaluate:

  • time spent fixing selectors
  • time spent keeping CI stable
  • time spent onboarding new contributors
  • time spent reviewing AI-generated code
  • time spent maintaining infrastructure

If those are large, a code-first tool may still be the wrong economic model, even if the demo looks faster.

Final take

Selenium and Playwright are still useful, and AI makes both more accessible. But AI does not erase the underlying ownership model.

  • Selenium remains the more mature, broad, and operationally heavy choice
  • Playwright is the better modern code-first choice for many new teams
  • both still create a maintenance burden when tests live as code
  • token usage, review time, and infrastructure all matter once AI enters the workflow

If your goal is to generate more browser code, AI assistants can help with either framework. If your goal is to reduce the long-term cost of maintaining automation, a platform like Endtest is often the more practical option because it combines agentic AI, editable tests, and self-healing behavior without forcing your team to own Selenium or Playwright infrastructure.

For a broader perspective on balancing automation cost and manageability, see Affordable AI Test Automation and the AI Test Automation: Practical Guide.