Install selenium-mcp to give Claude Code a real browser. It writes standard Selenium tests with accurate locators from live page inspection, integrating into your existing Java project.
Key Takeaways
- Install selenium-mcp to give Claude Code a real browser.
- It writes standard Selenium tests with accurate locators from live page inspection, integrating into your existing Java project.
What Changed — selenium-mcp gives Claude Code eyes on your page
If you've ever asked Claude Code to write a Selenium test, you know the pain: it guesses locators from pasted HTML, misses dynamic elements, and produces tests that fail on the first run. selenium-mcp (github.com/Volta-Jebaprashanth/selenium-mcp) fixes that by giving your AI agent a real Selenium WebDriver session it can drive directly. It's a Java-based MCP server that exposes 112 tools across 16 categories—including openBrowser, navigate, getPageElementsFiltered, waitForNetworkIdle, and REST Assured API tools.
Instead of hallucinating selectors, Claude Code inspects the live DOM, gets disambiguated locators, and writes tests that actually work. The output is plain Java with standard Selenium—no proprietary runtime dependency.
What It Means For You — No more guessing locators
For test automation engineers, this is a game-changer. You can now prompt Claude Code to:
-
Inspect a page and write a test — Claude opens Chrome, navigates to your staging URL, finds the email and password fields with
getPageElementsFiltered, and writes aLoginPageTestclass in your existing Page Object style. -
Diagnose flaky tests — Use
NetworkToolslikewaitForNetworkIdleandgetNetworkLogto pinpoint timing issues. - Refactor brittle locators — Point Claude at an existing Page Object and ask it to improve selectors using live element discovery.
Since Claude works in your Maven project, it follows your conventions—TestNG, JUnit 5, whatever you use—and writes files directly into src/test/java.
Try It Now — Setup and your first prompt
Step 1: Download the jar — Grab the latest release from GitHub. You need Java 21+ and a local Chrome, Firefox, or Edge (WebDriver binaries auto-fetch).
Step 2: Add to Claude Code config — Add this to your MCP server config (e.g., ~/.claude.json or project .mcp.json):
{
"mcpServers": {
"selenium-mcp": {
"command": "java",
"args": ["-jar", "/absolute/path/to/selenium-mcp.jar"]
}
}
}
Step 3: Open Claude Code in your Maven project — Ensure you're in the workspace with your existing Java/Selenium tests.
Step 4: Prompt for a real test — Try this:
"Open Chrome and navigate to our staging login page at
https://staging.example.com/login. Inspect the email and password fields using the page element tools, then write aLoginPageTestclass in our existingLoginPagePage Object style, using TestNG, that logs in with a valid test user and asserts we land on the dashboard."
Watch the tool calls: openBrowser, navigate, getPageElementsFiltered. Claude writes the test with real locators and waits.
Step 5: Run and review — Run mvn test and review the output like a teammate's PR. It's standard Selenium code.
Go further: Ask Claude to add REST Assured API checks via ApiTools, or debug a flaky test with NetworkTools.
Why It Works — Seeing beats guessing
The core problem with AI-generated tests is hallucinated selectors. selenium-mcp gives Claude a live browser session, so it can query the actual DOM, get ancestor/sibling-disambiguated locators, and verify element visibility. Combined with CDP network tools, it can even wait for network idle—addressing the #1 cause of flaky tests.
When To Use It
- You're writing new Selenium tests and want them right the first time.
- You have flaky tests that need diagnosis.
- You're refactoring Page Objects and want accurate locators.
Skip it if you're not on Java/Selenium—this is built specifically for that stack.
Source: dev.to
Originally published on gentic.news

Top comments (0)