Browser automation via Selenium WebDriver
## Selenium MCP Server: Browser Automation Framework The **Selenium MCP Server** integrates the industry-standard browser automation framework into Google Antigravity, enabling developers to automate web browsers for testing and scraping with full WebDriver support. ### Why Selenium MCP? - **Cross-browser** - Chrome, Firefox, Safari, Edge support - **WebDriver standard** - W3C WebDriver protocol - **Grid support** - Distributed browser execution - **Screenshot capture** - Visual testing support - **Element interaction** - Full DOM manipulation ### Key Features #### 1. Browser Sessions ```python # Create browser session session = await mcp.call("selenium", "create_session", { "browser": "chrome", "options": { "headless": True, "window_size": [1920, 1080] } }) print(f"Session ID: {session[\"sessionId\"]}") # Navigate to URL await mcp.call("selenium", "navigate", { "session_id": session["sessionId"], "url": "https://example.com" }) ``` #### 2. Element Interaction ```python # Find element element = await mcp.call("selenium", "find_element", { "session_id": session["sessionId"], "using": "css selector", "value": "input[name=email]" }) # Type text await mcp.call("selenium", "send_keys", { "session_id": session["sessionId"], "element_id": element["ELEMENT"], "text": "user@example.com" }) # Click button button = await mcp.call("selenium", "find_element", { "session_id": session["sessionId"], "using": "css selector", "value": "button[type=submit]" }) await mcp.call("selenium", "click", { "session_id": session["sessionId"], "element_id": button["ELEMENT"] }) ``` #### 3. Page Content ```python # Get page source source = await mcp.call("selenium", "get_page_source", { "session_id": session["sessionId"] }) # Get element text text = await mcp.call("selenium", "get_element_text", { "session_id": session["sessionId"], "element_id": element["ELEMENT"] }) ``` #### 4. Screenshots ```python # Take screenshot screenshot = await mcp.call("selenium", "screenshot", { "session_id": session["sessionId"] }) # Save to file with open("screenshot.png", "wb") as f: f.write(base64.b64decode(screenshot["value"])) ``` ### Configuration ```json { "mcpServers": { "selenium": { "command": "npx", "args": ["-y", "@anthropic/mcp-selenium"], "env": { "SELENIUM_GRID_URL": "http://localhost:4444" } } } } ``` ### Use Cases **E2E Testing**: Automated end-to-end browser tests. **Web Scraping**: Extract data from dynamic pages. **Form Automation**: Automate form submissions. **Visual Testing**: Capture screenshots for comparison. The Selenium MCP Server enables cross-browser automation.
{
"mcpServers": {
"selenium": {
"mcpServers": {
"selenium": {
"args": [
"-y",
"selenium-mcp-server"
],
"command": "npx"
}
}
}
}
}