Playwright IA: Midscene.js
Automate Playwright flows using natural language with Midscene.js and AI.
Playwright IA: Midscene.js
Proyecto de automation con Playwright e inteligencia artificial (Midscene).
-
Instala dependencias, ejecuta tests y visualiza el reporte para tener un primer vistazo del modo en que opera Midscene.
-
Configura el MCP Server de Midscene para que automatize lo que le pidas desde un prompt.
📥 Instalación
Instalar dependencias:
npm install
# o
yarn install
▶️ Ejecución de pruebas
Primero exporta tu API_KEY:
#linux
export OPENAI_API_KEY="tu_api_key"
Ejecuta los tests con Playwright y genera un reporte en HTML:
npx playwright test
Si deseas ver el proceso de ejecución:
npx playwright test --headed
📂 Abrir el reporte
Para visualizar el reporte generado, usa el comando:
open midscene_run/report/tu_reporte.html
Se abrirá automáticamente una ventana del navegador con el dashboard de resultados (flujos de MidSceneJS, capturas y trazas).
📂 MidScene: APIs básicas de operación de IA
Usa estas APIs en tus steps para que la IA haga el trabajo.
- ai o aiAction – Interacción general con IA
- aiTap – Operación de clic
- aiHover – Operación de hover (pasar el cursor)
- aiInput – Operación de entrada de texto
- aiKeyboardPress – Operación de teclado
- aiScroll – Operación de desplazamiento
- aiQuery – Consulta a IA
- aiAssert – Aserción de IA
- aiWaitFor – Espera basada en IA
Puedes encontrar más detalles en midscenejs.com/api
🧠 MidScene: MCP Server
Permite usar lenguaje natural para automatizar flujos y generar pruebas con Playwright, utilizando el agente de inteligencia artificial MidScene a través de su MCP Server.
✅ Requisitos
- Instala Cursor.
- Abre este proyecto con Cursor.
- Configura el MCP en Cursor.
⚙️ Configuración del MCP en Cursor
- Abre Cursor
- Ve a:
File > Preferences > Settings - Agrega la siguiente configuración en el apartado MCP:
{
"mcpServers": {
"mcp-midscene": {
"command": "npx",
"args": ["-y", "@midscene/mcp"],
"env": {
"MIDSCENE_MODEL_NAME": "gpt-4o-mini",
"OPENAI_API_KEY": "<OPENAI_API_KEY>",
"MCP_SERVER_REQUEST_TIMEOUT": "800000"
}
}
}
}
- No olvides ingresar tu OPENAI_API_KEY en el json.
🤖 Enviar prompt en Cursor
Abre un chat en Cursor (Ctrl + N) y escribe tu prompt. Por ejemplo:
Usa el MCP de Midscene para:
1. Open page https://practicetestautomation.com/practice-test-login/
2. Type username incorrectUser into Username field
3. Type password Password123 into Password field
4. Push Submit button
5. Verify error message is displayed
6. Verify error message text is Your username is invalid!
Al finalizar:
Crea el test case en Playwright con midscene, en la carpeta e2e con nombre login, usa de ejemplo @sauce-demo.spec.ts
Exporta OPENAI_API_KEY que esta en @mcp.json
Ejecuta el test npx playwright test e2e/login.spec.ts --headed
Nota: En el prompt, brinda contexto (ej: "@mcp.json"). De esta manera, Midscene encuentra la información necesaria para cumplir tu solicitud con éxito (templates, API_KEYS, etc).
เซิร์ฟเวอร์ที่เกี่ยวข้อง
Scout Monitoring MCP
ผู้สนับสนุนPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
ผู้สนับสนุนAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
ASKME-CLI
A command-line interface to prompt users for their next plan or confirmation.
MCP Command Server
A server for securely executing commands on the host system, requiring Java 21 or higher.
MCP QEMU VM Control
Give your AI full computer access — safely. Let Claude (or any MCP-compatible LLM) see your screen, move the mouse, type on the keyboard, and run commands — all inside an isolated QEMU virtual machine. Perfect for AI-driven automation, testing, and computer-use experiments without risking your host system.
x402engine
50+ pay-per-call APIs for AI agents via HTTP 402 crypto micropayments. $0.001–$0.12 per call with USDC and USDm.
Devopness
Devopness MCP server for DevOps happiness! Empower AI Agents to deploy apps and infra, to any cloud.
Bitcoin & Lightning Network
Interact with the Bitcoin and Lightning Network to generate keys, validate addresses, decode transactions, and query the blockchain.
Safe File MCP
A test server demonstrating all features of the MCP protocol, including prompts, tools, resources, and sampling.
Notifly MCP Server
Notifly MCP Server - enabling AI agents to provide real-time, trusted Notifly documentation and SDK code examples for seamless integrations.
MCP Base Server
A base template for creating new MCP servers, designed for easy containerized deployment with Docker.
OpenAPI MCP Server
Explore and analyze OpenAPI specifications from local files or remote URLs.