自动化测试框架

一个结合Playwright和GitHub Copilot的自动化测试框架,支持通过自然语言生成测试脚本。

  • by TheGatogol
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 TheGatogol/mcp-test-automation

使用说明

🎭 剧作家 + GitHub Copilot 框架

使用GitHub Copilot生成自然语言测试的自动化测试框架。

先决条件

  • Node.js 16及以上版本
  • VS Code Insiders(开发者预览版) (文件等)附有扩展内容/附件 GitHub Copilot (需订阅)
    • 下载地址:https://code.visualstudio.com/insiders/

安装

# Clonar el repositorio
git clone https://github.com/TheGatogol/mcp-test-automation.git
cd mcp-test-automation

# Instalar todo automáticamente (dependencias + navegadores)
npm run setup

使用Copilot创建测试

  1. 创建一个空文件 tests/practicaTestQAcademy.spec.js

  2. 将这段文字复制并粘贴到文件中:

Crea un archivo de Playwright llamado practicaTestQAcademy.spec.js que haga los siguientes pasos:
1. Importar test y expect de @playwright/test
2. Crear un test llamado "Login en TestQAcademy"
3. Navegar a https://practica.testqacademy.com/
4. Escribir "admin" en el campo con id qa-username-input
5. Escribir "123456" en el campo con id qa-password-input
6. Hacer click en el botón con id qa-login-button
7. Verificar que el login fue exitoso
Al terminar de generar el archivo:
Ejecuta el test que acabas de generar.
  1. 选择全部文本 并按下 Ctrl+I 以开启内联Copilot Chat

  2. Copilot 将生成测试代码

  3. 接受代码并授予写入权限 并删除指令文本

  4. 手动执行测试:

npx playwright test practicaTestQAcademy.spec.js --headed

执行测试

# Ejecutar todos los tests
npx playwright test

# Ejecutar un test específico
npx playwright test nombre.spec.ts

# Ver tests ejecutándose en navegador
npx playwright test --headed

# Modo debug paso a paso
npx playwright test --debug

# Abrir reporte HTML
npx playwright show-report

# Generar selectores (abre navegador interactivo)
npx playwright codegen https://practica.testqacademy.com/

结构

├── tests/                 # Tus tests van aquí
├── test-results/          # Videos y traces (se genera automáticamente)
├── playwright-report/     # Reportes HTML (se genera automáticamente)
├── playwright.config.js   # Configuración
└── package.json

调试

如果测试失败:

  1. 查看视频 在 test-results/
  2. 打开轨迹:
npx playwright show-trace test-results/[carpeta]/trace.zip

Copilot使用技巧

  • 在评论中要具体明确
  • 使用元素的确切ID(qa-username-input,qa-password-input,等)
  • 列出测试的步骤
  • 包括最后的验证

开发者

何塞·罗德里戈·埃斯库蒂亚·里奥斯
📧 rodrigoingsis@gmail.com(电子邮箱地址,可直接翻译为“电子邮箱:rodrigoingsis@gmail.com”,但为保持原格式,此处仅做符号说明)


有问题吗?检查一下:

  • GitHub Copilot已在VS Code Insiders中启用
  • 选择器与实际页面相匹配
  • 页面加载正常