Skip to content
web-infra-devPublic

About

See interfaces like a human. E2E testing in natural language.

Topics

Resources

Contributing

Stars

15.8k stars

Watchers

70 watching

Forks

Repository files navigation

Midscene.js
Use the UI like a user.
Vision-driven E2E testing in natural language — a GUI Agent and a newly designed test framework for web, mobile, and desktop apps.

Website · English / 简体中文

npm version downloads License E2E by Midscene.js Featured on GitHub Trending

Back to the essence of E2E testing with vision

E2E testing should verify the interface, not its code structure. Tests tied to UI code structure are inherently fragile — and even more importantly, they cannot tell whether a user can actually understand and use the interface, or whether the UI conveys the right information.

In the AI-native era, vision models give us the ability to test closer to the essence of E2E — looking at the screen to act and judge like a user. With accuracy and cost now in balance, the next stage of E2E testing is already here.

Write a test in natural language

Describe what a user wants to do and what they should see. You can organize tests in YAML with Midscene Test, or add the GUI Agent directly to your existing test suite.

YAML test cases with Midscene Test

After creating a Midscene Test project and configuring a model and the Web runtime, write a case like this. Replace the example URL with your app's address:

beforeEach:
  - gotoUrl: https://your-shop.example

cases:
  - name: Find headphones under $100
    steps:
      - aiAct: Search for headphones and filter the results to prices under $100
      - aiWaitFor: The filtered search results are visible
      - aiAssert: There are products in the search results, and each costs less than $100

JavaScript in your existing tests

You can also use the Agent directly in your existing tests. Configure a model and open your app in a Playwright page, then describe the same steps in code:

import { PlaywrightAgent } from '@midscene/web/playwright';

const agent = new PlaywrightAgent(page);

await agent.aiAct('Search for headphones and filter the results to prices under $100');
await agent.aiWaitFor('The filtered search results are visible');
await agent.aiAssert('There are products in the search results, and each costs less than $100');

For mobile and desktop apps, use the platform Agent with Rstest or Vitest. Open the generated HTML report to inspect screenshots, element locations, the AI decision process, and action and assertion results.

👁️ Operate and verify by vision alone

Midscene reads screenshots rather than code, testing the interface the way a user uses it: observe the screen, act on what is visible, and verify what the user actually sees.

Locate and act from screenshots

Midscene locates elements by their appearance and position, then clicks, types, or scrolls to carry out your instructions. You can target icon-only buttons, custom controls, <canvas>, and elements inside cross-origin iframes without maintaining selectors or adding semantic annotations.

Verify what users see

Describe the expected appearance in natural language to check colors, selection highlights, layout, and visual feedback — including content drawn on <canvas> or displayed in native apps.

await agent.aiAssert('The selected plan has a blue border and a checkmark');
await agent.aiAssert('The error message is visible below the email field');

🌐 One API, across platforms

Visual localization does not depend on the UI rendering stack or code structure, so the same Agent APIs work on every platform:

Platform Integration
Web Playwright, Puppeteer, or desktop Chrome
Android Devices and emulators through ADB
iOS Devices and simulators through WebDriverAgent
HarmonyOS HarmonyOS NEXT through HDC
Desktop macOS, Windows, and Linux, with remote RDP support
Custom interfaces Provide screenshots and action capabilities

📊 Reliability and cost in practice

Today's vision models strike a strong balance between accuracy and price, making pure vision testing practical for everyday E2E runs.

Choose models for your needs and budget

Screenshot-based UI actions avoid sending large DOM trees to the model. In the reported AppControlBench run, Midscene with Doubao Seed 2.1 Turbo passed 58 of 60 tasks with $0.59 in total model cost. The report provides per-task costs and comparisons across models.

Midscene supports GPT, Qwen, Doubao Seed, DeepSeek, Gemini, Kimi, and more, including open-source options you can self-host. See Model Selection Guide to choose a model and Model Configuration to set it up.

Benchmarks

Benchmark Pass@1 Model used in the reported run
AndroidWorld 93.1% Gemini-3.5-Flash
MobileWorld 78.6% Gemini-3.6-Flash
AppControlBench 96.7% Doubao Seed 2.1 Turbo

Each report includes the run configuration and task results; see AndroidWorld's report for its environment and validator adjustments. Explore cross-platform showcases, from web form validation to mobile workflows and community-built in-vehicle testing.

🧩 Midscene Test: what an E2E framework looks like when tests are pure intent

Through extensive practice, we found that once vision models handle UI interaction and verification, what remains in a test case is pure intent. At that point, traditional test frameworks built around hand-coded locators and page objects become unnecessary overhead.

Midscene Test (@midscene/test) starts from that premise to rethink what an AI-native E2E framework should optimize for: expressing test cases as pure intent, encapsulating deterministic business operations as reusable capabilities, and letting engineers and AI agents maintain the same test suite together.

Separate intent from business logic, maintained by people and AI

  • Describe test cases in YAML. Combine UI actions, assertions, and business operations to express the flow and expected results.
  • Reuse business capabilities through TypeScript Nodes. Wrap data preparation, API calls, and cleanup in Nodes that different cases can share. A refund test can prepare an order through an API, request a refund through the UI, and verify the result in one workflow.
  • Generate a Node Spec for developers and AI agents. Export registered Nodes and their inputs as Markdown, so both can write cases without reading TypeScript.

Engineering foundation built for visual agents

  • Multi-project orchestration: run web, Android, iOS, and desktop suites from one config with --project and tag filtering.
  • Concurrency and isolation: maxConcurrentFiles, with fileSetup giving each file its own page, Agent, or device.
  • Lifecycle hooks and cleanup: setup, fileSetup, beforeAll, and beforeEach with reverse-order cleanup that still runs after timeouts or Ctrl+C.
  • Retries and timeouts: case retries after cleanup, step timeouts, continue-on-error, and bail.
  • Visual reports & CI integration: interactive HTML replay for every Plan, Locate, and action, official midscene-action for GitHub Actions with #runner-step=last-error deep links, live badges, model verify, and summary.json / result.md for scripts and AI agents.

Start with Create and use test projects, then learn how to Develop custom Nodes and control lifecycle and concurrency.

Reports, Test results, caches and logs are saved in midscene_run/. See artifact directories for configuration and CI archiving.

🚀 Get started

📄 Resources

🤝 Community

🌟 Awesome Midscene

Community projects that extend Midscene.js capabilities:

📝 Credits

We would like to thank the following projects:

📖 Citation

If you use Midscene.js in your research or project, please cite:

@software{Midscene.js,
  author = {Xiao Zhou, Tao Yu, YiBing Lin},
  title = {Midscene.js: GUI Agent for E2E Testing.},
  year = {2025},
  publisher = {GitHub},
  url = {https://github.com/web-infra-dev/midscene}
}

⭐ Star Midscene

If Midscene is useful to you, please give it a star.

Star History Chart

📝 License

Midscene.js is MIT licensed.

About

See interfaces like a human. E2E testing in natural language.

Topics

Resources

Contributing

Stars

15.8k stars

Watchers

70 watching

Forks

Releases

Packages

Used by

Contributors

Languages