Works in VS Code with GitHub Copilot's Agent mode to generate Playwright locators, analyze pages, create Page Object Models, and run/generate test automation scripts through natural language chat.
Generates Page Object Model classes and test scripts in JavaScript for Playwright test automation, with support for intelligent locator generation and reliability rankings.
Generates Page Object Model classes and test scripts in Python for Playwright test automation, with support for intelligent locator generation and reliability rankings.
Generates Page Object Model classes and test scripts in TypeScript for Playwright test automation, with support for intelligent locator generation and reliability rankings.
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!
β‘ One-Click Install
β¨ Features
Feature | Description |
π― Get Locators | Get all possible locators for any element with reliability rankings |
π Analyze Page | Scan pages and identify all interactive elements |
ποΈ Generate POM | Auto-generate Page Object classes (TypeScript/JavaScript/Python) |
β Run Tests | Execute Playwright tests and get pass/fail results |
π Generate Tests | Create executable test scripts |
π Quick Start
For VS Code (v1.99+ with GitHub Copilot)
One-Line Install (Mac/Linux):
One-Line Install (Windows PowerShell):
Or Manual Setup:
Open Command Palette (
Cmd+Shift+P/Ctrl+Shift+P)Type:
MCP: Add ServerSelect:
Command (stdio)Command:
npxArgs:
-y locatorlabs-mcp
Using with GitHub Copilot:
Enable Agent Mode: Settings β Search
chat.agent.enabledβ EnableOpen Copilot Chat (
Ctrl+Cmd+I/Ctrl+Alt+I)Switch to Agent mode (dropdown at top)
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.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
Step 2: Add this configuration:
Step 3: Restart Claude Desktop
For Cursor IDE
One-Line Install:
Or Manual: Go to Cursor Settings β MCP β Add new MCP Server
Name:
locatorlabsCommand:
npx -y locatorlabs-mcp
For VS Code + Cline Extension
Add to Cline MCP settings:
π 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 |
| 98% |
role |
| 95% |
id |
| 90% |
Analyze Entire Page
"Analyze all form elements on https://www.saucedemo.com"
Generate Page Object Model
"Generate a TypeScript Page Object for https://www.saucedemo.com and call it LoginPage"
Run a Test
"Run a test that logs into saucedemo.com with standard_user and secret_sauce, then verify Products page appears"
Response:
Generate Test Script
"Generate a Python test script for the saucedemo login flow"
π οΈ Available Tools
Tool | Description |
| Get all possible locators for a specific element |
| List all interactive elements on a page |
| Create POM class (TypeScript/JavaScript/Python) |
| Execute tests in real browser, get pass/fail |
| Generate executable test scripts |
π― Supported Test Actions
Action | Description |
| Go to URL |
| Click element |
| Enter text |
| Clear input field |
/
| Toggle checkbox |
| Select dropdown option |
| Mouse hover |
| Keyboard key press |
| Verify element visible |
| Verify element hidden |
| Verify text content |
| Verify input value |
| Verify page URL |
| Verify page title |
| Wait for time |
| Wait for element |
| Capture screenshot |
π Locator Priority
LocatorLabs ranks locators by reliability:
data-testid (98%) - Best, explicitly for testing
Role + Name (95%) - Playwright recommended
Label (90%) - Accessible
ID (90%) - Stable if meaningful
Placeholder (85%) - Good for inputs
Text (75%) - May change
CSS (60%) - Can be brittle
XPath (40%) - Avoid unless necessary
π LocatorLabs vs Playwright MCP
Feature | Playwright MCP | LocatorLabs MCP |
Get all locators for element | β | β |
Locator reliability ranking | β | β |
Generate Page Object Model | β | β |
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
Permission issues on Mac
View logs (Claude Desktop)
Auto-approve tools in VS Code
Add to settings.json:
π€ Contributing
Contributions welcome! Please open an issue or PR on GitHub.
πΊ Author
Naveen AutomationLabs
YouTube: @naveenautomationlabs (415K+ subscribers)
Website: naveenautomationlabs.com
LinkedIn: Naveen AutomationLabs
π License
MIT
Made with β€οΈ for the test automation community