Open-source project
web-infra-dev/midscene avatar
web-infra-dev/midscene

Midscene.js: Vision-Driven UI Automation That Ignores the DOM

AI-powered, vision-driven UI automation for every platform. Two ways to test, add Midscene to your Playwright / Vitest suite, or let an AI agent test autonomously via Skills.

14,893 stars1,153 forksTypeScriptMIT

At a glance

What is it?
Midscene.js automates web, mobile, and desktop interfaces by reading screenshots instead of selectors. It trades DOM dependency for multimodal model cost and nondeterminism.
Who is it for?
Adopt Midscene.js if your UI automation breaks on selectors, you need to test canvas or native apps, or you want to assert visual state. Skip it if you require deterministic, low-cost runs or must avoid sending screenshots to external models.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly TypeScript, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 14, 2026, and from our analysis. They are not legal advice.

DEEP OPEN-SOURCE ANALYSIS

The Problem: Selectors Break, Vision Doesn't

Traditional UI automation depends on the DOM or accessibility tree. That structure is fragile: selectors break on refactor, elements without semantic markup are invisible, and native apps and cross-origin iframes are out of reach. Midscene.js attacks this by working from the screenshot alone. You describe each step in natural language, and the tool locates elements visually. This removes the maintenance burden of chasing selectors. It also reaches surfaces that DOM-based tools cannot touch, such as canvas, native apps, and iframes. The trade-off is immediate: you trade deterministic locators for model inference, which costs money and introduces variability.

Two Ways to Test: In-Suite or Autonomous Agent

Midscene.js offers two integration paths. First, you can add it to a Playwright or Vitest suite, using methods like aiAct, aiQuery, and aiAssert. This keeps your existing test runner and CI flow. Second, you can hand automation to an AI agent via Midscene Skills, which works with OpenClaw to test web, mobile, and desktop interfaces autonomously. The README presents these as complementary: one for scripted tests, the other for agent-driven exploration. The agent path is newer and less proven, but it suits scenarios where you want the AI to decide steps rather than follow a script.

How It Works: Pure Vision with Optional DOM

The core mechanism is screenshot-based element localization. Midscene.js is 'all-in on pure vision' for UI actions, meaning the model sees pixels, not HTML. This is what lets it handle icon-only buttons, custom controls, and canvas. For data extraction and page understanding, you can opt in to include DOM when needed. That optionality is useful: you get vision's reach for actions, but you can still use structured data for assertions that need exact values. The documentation mentions model strategy as a separate page, but the README already lists supported models: Qwen3.x, Doubao-Seed-2.1, GLM-4.6V, gemini-3.5-flash, and UI-TARS. The last one is open-source and self-hostable, which addresses privacy concerns.

Getting Started: Commands and Platforms

The README points to a quick start that configures a model, installs a Chrome extension, and runs a natural-language instruction. For scripted use, you create an Agent and run a complete browser script with Playwright or Puppeteer. The integration guides for Android, iOS, HarmonyOS, and desktop are separate pages. The API reference lists common methods like aiAct, aiQuery, and aiAssert. The actual setup commands are not in the README, so you must follow the documentation links. That is a gap: the README teases but does not show a single install command. You will need to visit midscenejs.com to get the exact npm package and configuration.

Limitations: Cost, Nondeterminism, and Model Dependency

The biggest limitation is that Midscene.js is only as good as the multimodal model driving it. The README names models with 'strong UI localization', but does not quantify accuracy. If your chosen model misidentifies an element, the test fails or acts wrongly. There is no fallback to a selector-based locator for critical steps. Second, every action requires a model call, which means per-test cost and latency. For a large suite, this could be expensive. Third, vision-only reasoning can be nondeterministic: the same screenshot might produce different actions across runs. This makes Midscene.js a poor fit for tests that require strict repeatability. It is also wrong for pure unit-level UI checks where a simple text assertion suffices.

Alternatives: DOM-Based AI Tools and Traditional Selectors

The README explicitly contrasts Midscene.js with 'AI tools that read the DOM or the accessibility tree'. Those tools, such as Playwright's own AI integrations or other LLM-driven testers, use page structure for localization. They are cheaper and more deterministic because they do not need to interpret pixels. The difference is fundamental: DOM-based tools can miss elements that vision can see, but they never misread a button's label if it is in the HTML. If your app is a standard web app with semantic markup, a DOM-based approach may be more reliable. If you test canvas or native apps, Midscene.js is the only option among these. The choice is between structural fidelity and visual reach.

Maintenance and Upgrade Costs

The repository is actively maintained, with releases in August 2026 and a default branch named main. The MIT license is permissive, so you can embed it without restrictive obligations. However, the maintenance cost is not zero. You must track model updates: a model provider's new version might change behavior, breaking your tests. The README lists multiple supported models, but each has its own quirks. You also need to manage API keys and costs. The community extensions, such as midscene-pc for desktop control or Midscene-Python for a Python SDK, are third-party and may lag behind core releases. Verify the compatibility of any extension before relying on it.

Who Should Adopt It and What to Verify First

Adopt Midscene.js if you are testing interfaces that resist DOM-based automation: canvas-heavy web apps, native mobile apps, or cross-origin iframes. It is also useful if you want to assert visual properties like colors and layout, which are invisible to DOM assertions. Do not adopt it if your tests are simple and stable with selectors, or if you cannot afford per-step model calls. Before committing, verify the model strategy documentation to see which models are supported and whether you can self-host UI-TARS. Run a proof-of-concept on a small suite with your chosen model. Check the API reference for aiAssert to see how it reports failures. The README promises reach and low maintenance, but those benefits depend entirely on the model behind the screenshots.

Editorial conclusion

Adopt Midscene.js if your UI automation breaks on selectors, you need to test canvas or native apps, or you want to assert visual state. Skip it if you require deterministic, low-cost runs or must avoid sending screenshots to external models. Before adopting, verify which multimodal models your team can access and whether their UI localization quality meets your tolerance for flaky steps. Check the model strategy docs for self-hosted options like UI-TARS, and test on a small non-critical suite first.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
  4. Release notes
Community notes

Community notes