midscene README

README проекта с github.com/web-infra-dev/midscene. Одним файлом markdown: README.md.

Midscene.js
Use the UI like a user.
Vision-driven E2E testing & GUI Agent for web, mobile, and desktop.

Website · English / 简体中文

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

Recreate user journeys to verify real experience

Real users interact with what's on the screen, not your DOM. As AI writes and refactors code faster than ever, what matters most in E2E testing is recreating real user journeys to verify the actual experience—yet most AI testing tools and Playwright MCP still translate intent into selector scripts, stuck in DOM replay.

Midscene skips script translation, using vision models to look at the screen, act on what's visible, and verify the rendered result directly:

Selector-based E2E vs. Vision-driven Midscene

Models and cost

Midscene is model-agnostic — bring Doubao Seed, Qwen, DeepSeek, Gemini, GPT, Kimi, MiMo, or any OpenAI-compatible / self-hosted endpoint (selection · setup). Because screenshot-based actions avoid sending large DOM trees, everyday E2E runs cost fractions of a cent per step (1280 × 720 / 720 × 1280 screenshots):

Model UI grounding steps / $1 Est. test runs / $1 (10 steps/run)
deepseek-v4.1-flash ≈ 20,164 ≈ 2,016
gpt-6-luna ≈ 4,901 ≈ 490
seed-2.0-mini ≈ 4,640 ≈ 464
qwen3.8-flash ≈ 4,141 ≈ 414
gemini-3.8-flash ≈ 729 ≈ 72

Estimated from screenshot pixel count and published reference prices. See the full 35-model model comparison report for accuracy, speed, and cost across real E2E cases.

Integrate with your workflow

Use the same visual Agent in YAML with Midscene Test, or directly in Playwright Test, Rstest, or Vitest:

YAML (Midscene Test)

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 (Playwright / Rstest / Vitest)

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');

Core APIs

Mix three levels of control in the same test (API reference):

Category APIs Use case
Autonomous goal aiAct Multi-step flows with scrolling, branches, or popups
Precise single action aiTap, aiInput, aiHover, aiScroll, aiKeyboardPress Single fixed action — faster, lower cost, more predictable
Read-only insight aiAssert, aiQuery, aiWaitFor, aiBoolean, aiString, aiNumber Visual assertions and structured data extraction

One API, across platforms

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

Midscene Test: a testing framework built for AI

Beyond the GUI Agent SDK, Midscene provides a standalone E2E testing framework (@midscene/test). Stick with the SDK if you already have Playwright or Vitest suites; use Midscene Test if you want a dedicated AI-native test project:

Docs: Create a test project · Develop custom Nodes · Lifecycle and concurrency · Artifacts

Get started

Resources

Community

Awesome Midscene

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 code is MIT licensed. The separately published @midscene/benchmark-grounding test set documents the licenses declared by its direct sources. See the test set license and attribution.

midscene (web-infra-dev/midscene)

Ищем в базе…

Что это такое?Midscene — это GUI-агент, который управляется по визуальной информации, вместе с набором для E2E-тестирования. Он смотрит на скриншоты, чтобы взаимодействовать с интерфейсом и проверять его в веб-, мобильных и десктопных приложениях через один набор Agent API.
Это плагин для Playwright или самостоятельный агент?Это собственный фреймворк для агентов (aiAct, aiTap, aiInput, aiAssert, aiQuery), который подключается к Playwright, Puppeteer или JS SDK либо управляется декларативно через YAML в Midscene Test. Это не обычный плагин для Playwright.
Как начать писать с ним тесты?Сначала попробуйте Playground или расширение для Chrome, затем пишите тесты с помощью SDK для Playwright/Puppeteer или в YAML через Midscene Test, настроив модель и указав ей существующую страницу Playwright.
Нужно ли подключать собственную AI-модель?Да — вы настраиваете мультимодальную модель, например Qwen3.x, Doubao-Seed-2.1, GLM-4.6V, gemini-3.5-flash или UI-TARS. Открытые модели можно развернуть у себя вместо платного API.
Он работает с DOM страницы, как селекторы Selenium?Нет — действия и проверки в основном опираются на скриншоты, чтобы не отправлять модели большие деревья DOM; для задач извлечения данных можно при желании включить передачу данных DOM.
Можно тестировать и мобильные, и десктопные приложения, а не только веб?Да — те же Agent API работают в Web, Android, iOS, HarmonyOS и десктопных приложениях, а сообщество расширяет их SDK для iOS Mirror, управления ПК на Windows/macOS/Linux (включая Docker-образ), Python и Java.
Какие основные API предоставляет Midscene?aiAct запускает автономные многошаговые сценарии, aiTap и aiInput выполняют отдельные действия, aiAssert проверяет визуальные ожидания, а aiQuery извлекает структурированные данные с экрана.
Насколько хорошо он показывает себя на реальных бенчмарках?Заявленные показатели Pass@1: 93,1% на AndroidWorld (Gemini-3.5-Flash), 78,6% на MobileWorld (Gemini-3.6-Flash) и 96,7% на AppControlBench (Doubao Seed 2.1 Turbo). Полный прогон AppControlBench из 60 задач обходится примерно в $0,59 за оплату модели.
Могут ли AI-агенты для написания кода тоже управлять интерфейсом через Midscene?Да, Midscene Skills позволяют AI-агентам для написания кода работать с интерфейсами, используя те же визуальные возможности Agent, а не только тестовые скрипты, написанные людьми.
Что такое Midscene Test?Это E2E-фреймворк в бета-версии, который отделяет сценарии интерфейса и ожидания, записанные в YAML, от переиспользуемых TypeScript-Node для вызовов API, подготовки данных и очистки. Также он включает шаблоны для быстрого старта, повторные попытки и автоматически генерируемую документацию по возможностям Node.
Автор
web-infra-dev
Размер
916.6 MB
Звёзды
15.8K
Возраст
2 г
Коммиты · 90 дней