Skip to content
gentic.news — AI News Intelligence Platform
Connecting to the Living Graph…

Listen to today's AI briefing

Daily podcast — 5 min, AI-narrated summary of top stories

A developer's terminal showing Claude Code interacting with selenium-mcp, with a browser window displaying a live…
Open SourceScore: 98

selenium-mcp: Let Claude Code Write Real Selenium Tests by Seeing the Page

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.

·19h ago·3 min read··19 views·AI-Generated·Report error
Share:
Source: dev.tovia devto_mcp, hn_claude_code, gn_claude_code, devto_claudecode, reddit_claudecodeMulti-Source
How do I use selenium-mcp to have Claude Code write Selenium tests that actually see the page?

Use selenium-mcp, a Java-based MCP server that gives Claude Code a live Selenium WebDriver. Install the jar, add it to your MCP config, and prompt Claude to inspect and test your page. It writes standard Selenium code in your existing project structure.

TL;DR

Install selenium-mcp to let Claude Code drive a real browser, inspect live elements, and write production-ready Selenium tests in your 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 a LoginPageTest class in your existing Page Object style.
  • Diagnose flaky tests — Use NetworkTools like waitForNetworkIdle and getNetworkLog to 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).

Image

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 a LoginPageTest class in our existing LoginPage Page 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

Sources cited in this article

  1. Claude
Source: gentic.news · · author= · citation.json

AI-assisted reporting. Generated by gentic.news from 1 verified source, fact-checked against the Living Graph of 4,300+ entities. Edited by Ala SMITH.

Following this story?

Get a weekly digest with AI predictions, trends, and analysis — free.

AI Analysis

**What to do differently**: Stop letting Claude Code guess locators from pasted HTML. Install selenium-mcp and give it a live browser. In your next session, prompt Claude to open a page and inspect it before writing any test code. This turns test generation from a gamble into a reliable process. **Specific tips**: Use `getPageElementsFiltered` to get disambiguated selectors. Ask for `waitForNetworkIdle` in your tests to avoid flakiness. Combine UI tests with `ApiTools` for data setup—Claude can seed data via REST Assured, then verify via UI. Always review the generated code like a human's PR—it's production code, not a toy.
This story is part of
Hugging Face Becomes the Neutral Ground Where Google and Anthropic's Agent Protocol War Converges
As Claude Code's MCP dominance threatens Google Cloud, Hugging Face's unique position as partner to both players creates an unexpected convergence zone
Compare side-by-side
Claude Code vs selenium-mcp
Enjoyed this article?
Share:

AI Toolslive

Five one-click lenses on this article. Cached for 24h.

Pick a tool above to generate an instant lens on this article.

Related Articles

From the lab

The framework underneath this story

Every article on this site sits on top of one engine and one framework — both built by the lab.

More in Open Source

View all