
基于 Python 的 Selenium 和 Pytest 自动化框架的 AI 驱动 MCP 集成,支持测试执行、结果检索、截图捕捉和 OWASP Juice 的失败证据收集...
概览
这是一个基于 Python 的 UI 和 API 自动化项目,用于 OWASP Juice Shop,并通过模型上下文协议(MCP)服务器进行了扩展,使 MCP 客户端能够发现并调用 QA 自动化工具。 该项目结合了 。它还在客户端工作流程中尝试本地 Ollama 模型(qwen2.5:1.5b)。 完整的 Pytest 套件已通过,测试有 3 次通过。已使用用于测试、检索结果、项目信息、截图和失败证据的 MCP 工具。当前客户端采用基于关键词的请求路由,因此不应被称为完全自主的 AI 代理。 - Selenium 用户界面自动化,用于登录和支付流程。- REST API 自动化,支持 Python 请求。- Pytest 夹具,用于共享浏览器设置和登录。- 用于测试数据的 JSON 文件。- 基于 Docker 的本地 Juice Shop 环境。- 用于测试执行、结果检索、截图和失败证据的 MCP 工具。- 结构化测试摘要,并附有原始 Pytest 输出。
概述(AI 翻译)
这是一个基于 Python 的 UI 和 API 自动化项目,用于 OWASP Juice Shop,并通过模型上下文协议(MCP)服务器进行了扩展,使 MCP 客户端能够发现并调用 QA 自动化工具。
该项目结合了 Pytest、Selenium WebDriver、Requests、Docker 和 MCP。它还尝试本地 Ollama 模型(qwen2.5:1.5b)作为客户端工作流程的一部分。
项目状态: 完整的 Pytest 套件已通过,测试有 3 次通过。已使用用于测试、检索结果、项目信息、截图和失败证据的 MCP 工具。当前客户端采用基于关键词的请求路由,因此不应被称为完全自主的 AI 代理。
特色
- Selenium 用户界面自动化,用于登录和支付流程。
- 带有 Python 请求的 REST API 自动化。
- 用于共享浏览器设置和登录的 Pytest 夹具。
- 用于测试数据的JSON文件。
- 基于 Docker 的本地 Juice Shop 环境。
- 用于测试执行、结果检索、截图和失败证据的MCP工具。
- 结构化测试摘要与原始 Pytest 输出并列。
- 当Selenium UI测试失败时,自动截图和回溯文本报告。
- 本地Ollama/Qwen实验。
技术栈
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
OWASP Juice Shop Automation with MCP
A Python-based UI and API automation project for OWASP Juice Shop, extended with a Model Context Protocol (MCP) server so an MCP client can discover and invoke QA automation tools.
The project combines Pytest, Selenium WebDriver, Requests, Docker, and MCP. It also experiments with a local Ollama model (qwen2.5:1.5b) as part of the client workflow.
Project status: The full Pytest suite was verified with 3 passing tests. The MCP tools for running tests, retrieving results, project information, screenshots, and failure evidence have been exercised. The current client uses keyword-based request routing, so it should not be described as a fully autonomous AI agent.
Features
- Selenium UI automation for login and payment flows.
- REST API automation with Python Requests.
- Pytest fixtures for shared browser setup and login.
- JSON files for test data.
- Docker-based local Juice Shop environment.
- MCP tools for test execution, result retrieval, screenshots, and failure evidence.
- Structured test summary alongside raw Pytest output.
- Automatic screenshot and traceback text report when a Selenium UI test fails.
- Local Ollama/Qwen experimentation.
Technology Stack
| Technology | Purpose |
|---|---|
| Python | Automation and MCP implementation |
| Pytest | Test discovery and execution |
| Selenium WebDriver | Browser UI automation |
| Requests | REST API automation |
| Docker | Runs Juice Shop locally |
| MCP Python SDK | Exposes QA capabilities as tools |
| Ollama + Qwen 2.5 1.5B | Local model experimentation |
| JSON | Test data |
| Git and GitHub | Version control and project hosting |
Project Structure
juice-shop-automation-mcp/
├── mcp/
│ └── server.py
├── screenshots/
│ ├── failures/
│ │ ├── _.png
│ │ └── _.txt
│ ├── all-tests.png
│ ├── api-test.png
│ ├── docker-running.png
│ ├── ui-test.png
│ ├── juice-shop-payment.png
│ └── mcp-received-screenshot.png
├── test_data/
│ ├── card-data.json
│ └── new-user.json
├── tests/
│ ├── test_cards_api.py
│ ├── test_login.py
│ └── test_payment.py
├── ai_client.py
├── conftest.py
├── requirements.txt
├── .gitignore
└── README.md
The exact screenshot files in a local checkout may differ depending on which tests have been run.
Architecture
User request
|
v
ai_client.py
|
| maps request to a tool
v
MCP client (ClientSession)
|
| session.call_tool(...)
v
mcp/server.py
|
+--> get_project_info
|
+--> run_tests ------> subprocess ------> Pytest
| |
| +--> Selenium UI tests
| +--> Requests API tests
|
+--> get_test_results
|
+--> get_screenshot
|
+--> get_failure_evidence
|
安装
docker run -d --name juice-shop -p 3000:3000 bkimminich/juice-shop