Selenium Self-Healing MCP Server
Automatically fixes broken Selenium test locators when UI changes occur, reducing test maintenance overhead.
README
Selenium Self-Healing MCP Server
An MCP server that automatically fixes broken Selenium test locators when UI changes occur, reducing test maintenance overhead.
Overview
When web UI changes break your automated tests, this MCP server intelligently finds alternative locators using multiple fallback strategies. Instead of failing immediately, it searches for elements by text content and visible attributes, returning the new working locator for future use.
Features
- Smart Fallback: Tries original CSS selector, then text matching, then visible element discovery
- Locator Return: Provides new working locators when originals fail
- Zero Configuration: Works out of the box with Chrome 143
- Container Isolated: Runs in secure Docker container
- AI-Friendly: Designed for AI assistant integration
Tools
open
Navigate to a URL.
Parameters:
url(string, required): Target URL
Example:
{
"url": "https://example.com"
}
Returns: Page title confirmation
click
Click an element with automatic self-healing.
Parameters:
locator(string, required): CSS selectordescription(string, optional): Text description for fallback search
Example:
{
"locator": "#submit-button",
"description": "login button"
}
Returns:
- Success: "Clicked!" or "Clicked! NEW LOCATOR: [new-selector]"
- Failure: "Could not find element even with self-healing"
type
Type text into an input field with automatic self-healing.
Parameters:
locator(string, required): CSS selectortext(string, required): Text to typedescription(string, optional): Text description for fallback search
Example:
{
"locator": "#username",
"text": "user@example.com",
"description": "username field"
}
Returns:
- Success: "Typed!" or "Typed! NEW LOCATOR: [new-selector]"
- Failure: "Could not find element even with self-healing"
screenshot
Capture current page screenshot.
Parameters: None
Returns: Base64 encoded PNG image
How Self-Healing Works
When a locator fails, the server attempts three strategies in order:
- Original CSS Selector: Try the provided locator
- Text Search: Search clickable elements (links, buttons) for matching text
- Visible Element Discovery: Find any visible element with an ID attribute
If a fallback succeeds, the server returns the new working locator.
Installation
Docker (Recommended)
docker pull mcp/selenium-selfhealing-mcp
From Source
git clone https://github.com/aiqualitylab/selenium-selfhealing-mcp.git
cd selenium-selfhealing-mcp
docker build -t selenium-selfhealing-mcp .
Usage
With Claude Desktop
Add to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"selenium": {
"command": "docker",
"args": ["run", "-i", "mcp/selenium-selfhealing-mcp"]
}
}
}
Restart Claude Desktop to load the server.
With Other MCP Clients
Run the Docker container with stdio:
docker run -i mcp/selenium-selfhealing-mcp
The server communicates via stdin/stdout using MCP protocol.
Example Usage
User: Open example.com and click using CSS #wrong-id with description "more information"
AI: Opened: example.com
Clicked! NEW LOCATOR: element
The server found the search button by text and returned the working selector.
Use Cases
- Test Maintenance: Automatically adapt tests when UI changes
- Exploratory Testing: Let AI discover correct locators through trial
- Test Migration: Update old tests with broken selectors
- CI/CD Resilience: Reduce flaky tests from minor UI changes
Requirements
- Docker
- Chrome 143+ (included in container)
- Python 3.11+ (included in container)
Error Handling
All tools return clear error messages:
- Network failures return connection errors
- Missing elements return "Could not find element" message
- Invalid URLs return navigation errors
Errors are logged but do not crash the server.
Security
- Runs in isolated Docker container
- No persistent storage of credentials
- Chrome runs with security flags (
--no-sandbox,--disable-dev-shm-usage) - No external network access except browsing
Limitations
- Chrome-only (no Firefox/Safari support)
- Headless mode only (no visual debugging)
- Text search is case-insensitive English
- Maximum 3 fallback strategies
Troubleshooting
Server won't start
- Ensure Docker is running
- Check port 9222 isn't in use
- Verify Chrome installation in container
Elements not found
- Provide descriptive text in
descriptionparameter - Wait for page load before clicking
- Check if element is in iframe (not supported)
ChromeDriver version mismatch
- Update to latest container image
- Chrome and ChromeDriver versions are pinned together
Contributing
Issues and pull requests welcome at: https://github.com/aiqualitylab/selenium-selfhealing-mcp
License
MIT License - See LICENSE file
Author
aiqualitylab
Changelog
v1.0.0 (2025-12-12)
- Initial release
- Basic self-healing with 3 strategies
- Chrome 143 support
- Docker containerization
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。