LocatorLabs MCP Server

LocatorLabs MCP Server

Generates intelligent Playwright locators with reliability rankings, creates Page Object Models, and runs test automation scripts directly from your IDE or AI assistant.

Category
访问服务器

README

LocatorLabs MCP Server

🎯 Intelligent Playwright locator generation powered by AI

An MCP (Model Context Protocol) server that provides smart locator generation for Playwright test automation.

Works directly in VS Code (with GitHub Copilot), Cursor, Windsurf, Cline, and Claude Desktop. No extra apps needed - just your favorite IDE!

npm version npm downloads

⚡ Quick Install

VS Code Cursor

VS Code (v1.99+) - Copy & run in terminal:

code --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Cursor:

cursor --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Windows PowerShell:

code --add-mcp '{\"name\":\"locatorlabs\",\"command\":\"npx\",\"args\":[\"-y\",\"locatorlabs-mcp\"]}'

✨ Features

Feature Description
🎯 Get Locators Get all possible locators for any element (Playwright + Selenium formats)
📊 Analyze Page Scan pages and identify all interactive elements
🏗️ Generate POM Auto-generate Page Object classes for Playwright & Selenium
Run Tests Execute Playwright tests and get pass/fail results
📝 Generate Tests Create executable test scripts

🔧 Supported Frameworks

Framework Locators Page Object Model
Playwright getByRole, getByTestId, etc. ✅ TypeScript, JavaScript, Python
Selenium By.id, By.xpath, By.cssSelector ✅ Java, Python, C#

🚀 Quick Start

For VS Code (v1.99+ with GitHub Copilot)

One-Line Install (Mac/Linux):

code --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

One-Line Install (Windows PowerShell):

code --add-mcp '{\"name\":\"locatorlabs\",\"command\":\"npx\",\"args\":[\"-y\",\"locatorlabs-mcp\"]}'

Or Manual Setup:

  1. Open Command Palette (Cmd+Shift+P / Ctrl+Shift+P)
  2. Type: MCP: Add Server
  3. Select: Command (stdio)
  4. Command: npx
  5. Args: -y locatorlabs-mcp

Using with GitHub Copilot:

  1. Enable Agent Mode: Settings → Search chat.agent.enabled → Enable
  2. Open Copilot Chat (Ctrl+Cmd+I / Ctrl+Alt+I)
  3. Switch to Agent mode (dropdown at top)
  4. Chat: "Get locators for login button on https://saucedemo.com"

For Claude Desktop

Step 1: Open config file

  • Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Step 2: Add this configuration:

{
  "mcpServers": {
    "locatorlabs": {
      "command": "npx",
      "args": ["-y", "locatorlabs-mcp"]
    }
  }
}

Step 3: Restart Claude Desktop

For Cursor IDE

One-Line Install:

cursor --add-mcp '{"name":"locatorlabs","command":"npx","args":["-y","locatorlabs-mcp"]}'

Or Manual: Go to Cursor Settings → MCP → Add new MCP Server

  • Name: locatorlabs
  • Command: npx -y locatorlabs-mcp

For VS Code + Cline Extension

Add to Cline MCP settings:

{
  "mcpServers": {
    "locatorlabs": {
      "command": "npx",
      "args": ["-y", "locatorlabs-mcp"]
    }
  }
}

📖 Usage Examples

Just chat naturally:

Get Locators for an Element

"Get me all locators for the login button on https://www.saucedemo.com"

Response:

Type Locator Reliability
testId getByTestId('login-button') 98%
role getByRole('button', { name: 'Login' }) 95%
id locator('#login-button') 90%

Analyze Entire Page

"Analyze all form elements on https://www.saucedemo.com"

Generate Page Object Model

Playwright:

"Generate a TypeScript Page Object for https://www.saucedemo.com and call it LoginPage"

Selenium:

"Generate a Java Selenium Page Object for https://www.saucedemo.com and call it LoginPage"

"Generate a C# Selenium Page Object for https://www.saucedemo.com called LoginPage"

"Generate a Python Selenium POM for https://www.saucedemo.com named LoginPage"

Run a Test

"Run a test that logs into saucedemo.com with standard_user and secret_sauce, then verify Products page appears"

Response:

✅ Test PASSED (3.2s)
- Navigate to login page ✅
- Enter username ✅
- Enter password ✅
- Click login ✅
- Verify Products visible ✅

Generate Test Script

"Generate a Python test script for the saucedemo login flow"

🛠️ Available Tools

Tool Description
get_locators Get all possible locators (Playwright + Selenium formats)
analyze_page List all interactive elements on a page
generate_page_object Create POM class (Playwright: TS/JS/Python, Selenium: Java/Python/C#)
run_test Execute tests in real browser, get pass/fail
generate_test Generate executable test scripts

📦 Supported Languages for Page Objects

Language Framework Example Output
typescript Playwright page.getByRole('button')
javascript Playwright page.getByRole('button')
python Playwright page.get_by_role('button')
java-selenium Selenium @FindBy(id = "btn")
python-selenium Selenium By.ID, "btn"
csharp-selenium Selenium [FindsBy(How = How.Id)]

🎯 Supported Test Actions

Action Description
navigate Go to URL
click Click element
fill Enter text
clear Clear input field
check / uncheck Toggle checkbox
select Select dropdown option
hover Mouse hover
press Keyboard key press
assert_visible Verify element visible
assert_hidden Verify element hidden
assert_text Verify text content
assert_value Verify input value
assert_url Verify page URL
assert_title Verify page title
wait Wait for time
wait_for_element Wait for element
screenshot Capture screenshot

🏆 Locator Priority

LocatorLabs ranks locators by reliability:

  1. data-testid (98%) - Best, explicitly for testing
  2. Role + Name (95%) - Playwright recommended
  3. Label (90%) - Accessible
  4. ID (90%) - Stable if meaningful
  5. Placeholder (85%) - Good for inputs
  6. Text (75%) - May change
  7. CSS (60%) - Can be brittle
  8. XPath (40%) - Avoid unless necessary

🔄 LocatorLabs vs Playwright MCP

Feature Playwright MCP LocatorLabs MCP
Get all locators for element
Locator reliability ranking
Selenium locator format
Generate Playwright POM
Generate Selenium POM (Java/C#/Python)
Run tests with pass/fail
Browser automation
Device emulation

They work great together! Use Playwright MCP for navigation/scraping, LocatorLabs MCP for locators/POMs/tests.

📋 Requirements

  • Node.js 18+
  • Playwright browsers (auto-installed on first run)

🔧 Troubleshooting

Playwright browsers not installed

npx playwright install chromium

Permission issues on Mac

chmod +x ~/.npm/_npx/*/node_modules/.bin/locatorlabs-mcp

View logs (Claude Desktop)

tail -f ~/Library/Logs/Claude/mcp*.log

Auto-approve tools in VS Code

Add to settings.json:

{
  "chat.tools.autoApprove": true
}

🤝 Contributing

Contributions welcome! Please open an issue or PR on GitHub.

📺 Author

Naveen AutomationLabs

📄 License

MIT


推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选