Add live browser action tools for direct Selenium control#5
Merged
Conversation
Adds 8 new MCP tools that let an AI agent drive a real browser step by step without generating or running a Robot Framework file: - browser_launch — open Chrome/Firefox (headless supported), navigate to URL - browser_navigate — go to a new URL in the active session - browser_click — click an element, waits for it to be clickable - browser_send_keys — type into an input, clears existing text by default - browser_get_text — read visible text from an element - browser_wait_for_element — wait for visible/present/clickable/hidden state - browser_screenshot — save a timestamped PNG and return its path - browser_close — quit the browser and clean up the session All tools share a module-level WebDriver session and support Robot Framework-style selector prefixes (id=, css=, xpath=, name=, class=, tag=, link=, partial_link=) with plain CSS as the default fallback. Also fixes a dead-code bug in create_extended_selenium_keywords where an unreferenced return template statement followed the actual return.
There was a problem hiding this comment.
Pull request overview
This PR extends the MCP server beyond Robot Framework code generation by adding “live” Selenium-driven browser action tools that operate against a shared module-level WebDriver session, enabling step-by-step browser control via MCP tool calls. It also removes a dead/unreachable return template in create_extended_selenium_keywords.
Changes:
- Added 8 new
browser_*MCP tools for launching, navigating, clicking, typing, reading text, waiting for elements, taking screenshots, and closing a shared Selenium session. - Implemented Robot Framework-style selector prefixes (
id=,css=,xpath=, etc.) with CSS as the fallback. - Removed unreachable dead code in
create_extended_selenium_keywords.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+205
to
+206
| service = webdriver.ChromeService() | ||
| _driver = webdriver.Chrome(options=opts, service=service) |
| service = webdriver.ChromeService() | ||
| _driver = webdriver.Chrome(options=opts, service=service) | ||
|
|
||
| _driver.maximize_window() |
| if clear_first: | ||
| element.clear() | ||
| element.send_keys(text) | ||
| return f"Typed into {selector}: '{text}'" |
Comment on lines
+191
to
+197
| if browser_lower == "firefox": | ||
| opts = FirefoxOptions() | ||
| if headless: | ||
| opts.add_argument("--headless") | ||
| _driver = webdriver.Firefox(options=opts) | ||
| else: | ||
| opts = ChromeOptions() |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New Tools
Example Usage
```python
browser_launch("https://example.com", browser="Chrome", headless=False)
browser_send_keys("id=username", "admin")
browser_send_keys("id=password", "secret")
browser_click("css=button[type='submit']")
browser_screenshot("results/after_login.png")
browser_close()
```
Test Plan