Selenium AI Agent

v3.9.0
io.github.learn-automated-testing/selenium-ai-agent Checked 9 hours ago Published 2 days ago

Selenium MCP: plan, review, generate, heal tests; JUnit/Allure reports linked to the plan

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

navigate_to

Navigate the browser to a URL. This is the primary and preferred navigation tool — starts a local browser automatically, no grid session or setup required. Use grid/session tools only when you need parallel browser sessions.

ParameterTypeDescription
url *stringURL to navigate to
expectationobject

go_back

Navigate back in browser history

ParameterTypeDescription
expectationobject

go_forward

Navigate forward in browser history

ParameterTypeDescription
expectationobject

refresh_page

Refresh the current page

ParameterTypeDescription
expectationobject

scroll_page

Scroll the page in a direction by a pixel amount, or scroll a specific element into view using a CSS selector.

ParameterTypeDescription
amountnumber
directionstring
expectationobject
selectorstring

capture_page

Capture the current page state including all interactive elements. Returns a structured snapshot with element references (e1, e2, etc.) that can be used for interactions.

ParameterTypeDescription
expectationobject

take_screenshot

Take a screenshot of the current page, viewport, full page, or specific element. Uses BiDi for full-page and element screenshots when available, falls back to classic API.

ParameterTypeDescription
expectationobject
filenamestring
formatstring
originstring
qualitynumber
refstring

click_element

Click on an element using its reference from the page snapshot

ParameterTypeDescription
ref *stringElement reference (e.g., e1, e2) from page snapshot
expectationobject

hover_element

Hover over an element using its reference from the page snapshot

ParameterTypeDescription
ref *stringElement reference (e.g., e1, e2) from page snapshot
expectationobject

select_option

Select an option from a dropdown by value, text, or index: a native <select>, or a dropdown list (combobox / picklist such as Salesforce Lightning), which is opened and the option clicked

ParameterTypeDescription
ref *stringElement reference for select element
expectationobject
indexnumber
textstring
valuestring

drag_drop

Drag and drop from source element to target element

ParameterTypeDescription
sourceRef *stringSource element reference from page snapshot (e.g. "e5")
targetRef *stringTarget element reference from page snapshot (e.g. "e10")
expectationobject

teach_selector

Teach the system a preferred CSS selector for an element. The selector is saved and used as Phase 0 (highest priority) in future element discovery on this domain.

ParameterTypeDescription
css *stringThe preferred CSS selector for this element
description *stringDescription of the element (e.g., "the NL language link", "the search button")
expectationobject
scopestring

input_text

Type text into an input field or textarea

ParameterTypeDescription
clear *boolean
ref *stringElement reference (e.g., e1, e2) for input field
text *stringText to type into the field
expectationobject

key_press

Press a keyboard key, optionally with modifiers (ctrl, alt, shift, meta)

ParameterTypeDescription
key *stringKey to press (e.g., "enter", "tab", "escape", "backspace", "up", "down")
expectationobject
modifiersarray
refstring

file_upload

Upload a file through a file input element

ParameterTypeDescription
filePath *stringPath to file to upload
ref *stringFile input element reference from page snapshot
expectationobject

mouse_move

Move mouse to specific coordinates

ParameterTypeDescription
x *numberX coordinate
y *numberY coordinate
expectationobject

mouse_click

Click on an element using mouse with specified button

ParameterTypeDescription
button *string
ref *stringElement reference from page snapshot
expectationobject

mouse_drag

Drag from one element to another

ParameterTypeDescription
fromRef *stringSource element reference
toRef *stringTarget element reference
expectationobject

tab_list

List all open browser tabs

ParameterTypeDescription
expectationobject

tab_select

Switch to a specific browser tab by index

ParameterTypeDescription
tabId *numberTab ID to select (0-based index)
expectationobject

tab_new

Open a new browser tab

ParameterTypeDescription
expectationobject
urlstring

tab_close

Close a specific browser tab

ParameterTypeDescription
tabId *numberTab ID to close (0-based index)
expectationobject

verify_element_visible

Verify that an element is visible on the page

ParameterTypeDescription
ref *stringElement reference from page snapshot
timeout *number
expectationobject

verify_text_visible

Verify that specific text is visible on the page

ParameterTypeDescription
text *stringText content to verify is visible on the page
timeout *number
expectationobject

verify_value

Verify that an element has the expected value or text content

ParameterTypeDescription
expectedValue *stringExpected value of the element
ref *stringElement reference from page snapshot
expectationobject

verify_list_visible

Verify that multiple text items are visible on the page

ParameterTypeDescription
items *arrayList of text items that should be visible
expectationobject

wait_for

Wait for a condition to be met (element visible, URL contains, etc.)

ParameterTypeDescription
condition *stringCondition to wait for
timeout *number
value *stringValue for condition (element selector or text to match)
expectationobject

execute_javascript

Execute JavaScript code in the browser context. Use "return" to get a value back.

ParameterTypeDescription
script *stringJavaScript code to execute in the browser
argsarray
expectationobject

resize_window

Resize or move the browser window, use a device preset (mobile, tablet, desktop, desktop-hd), or change its state: fullscreen (whole screen and in front, ideal for demos and screen recordings), maximize, minimize (out of view, so the AI chat or another app is visible again), or normal (restore)

ParameterTypeDescription
expectationobject
heightnumber
presetstring
statestring
widthnumber
xnumber
ynumber

dialog_handle

Handle browser dialogs (alert, confirm, prompt)

ParameterTypeDescription
action *stringDialog action: accept, dismiss, or get_text
expectationobject
textstring

console_logs

Get browser console logs or clear console. Uses BiDi event collector when available for cross-browser support, falls back to classic log API.

ParameterTypeDescription
action *stringConsole action: get_logs or clear
level *string
expectationobject

network_monitor

Monitor network requests or control network state

ParameterTypeDescription
action *stringNetwork action
offline *boolean
expectationobject

pdf_generate

Generate a PDF from the current page. Uses BiDi printPage for cross-browser support (Chrome, Firefox, Edge), falls back to CDP.

ParameterTypeDescription
format *string
landscape *boolean
printBackground *boolean
expectationobject
filePathstring
pageRangesstring
scalenumber

close_browser

Close the browser and end the session

ParameterTypeDescription
expectationobject

reset_session

Reset the browser session (close and restart browser)

ParameterTypeDescription
expectationobject

set_stealth_mode

Enable or disable stealth mode, which masks basic automation flags (navigator.webdriver, the "controlled by automated software" bar). Useful when testing your own site behind simple bot checks; it does not get past advanced bot protection such as Cloudflare challenges. If the browser is already running it will be restarted with the new setting.

ParameterTypeDescription
enabled *booleanEnable (true) or disable (false) stealth mode
expectationobject

batch_execute

Execute multiple tool steps in a single round trip. Intermediate steps skip snapshots by default; the last step includes a snapshot. Max 20 steps. Cannot call batch_execute recursively.

ParameterTypeDescription
steps *arrayArray of tool steps to execute sequentially (max 20)
stopOnFirstError *boolean
expectationobject
globalExpectationobject

get_selenium_docs

Read the current Selenium (or WebdriverIO) documentation as Markdown, from the projects' own llms.txt indexes. Use it before writing or fixing code with an API you are not sure of: an API that is not in the current docs or API reference does not exist (Selenium's guidance for AI agents). Without "page" it returns the docs index (https://www.selenium.dev/llms.txt); with a URL, path or topic it returns that page, with the code examples for every language. Only selenium.dev and webdriver.io are fetched; pages are cached for a day.

ParameterTypeDescription
expectationobject
frameworkstring
pagestring

agent_profile

Show or set the determinism profile: how much the agent may do on its own. explore (default) today's behaviour: plan review and Selenium's rules, nothing extra. guided a person approves intent: approved plans only, heals that change assertions or remove steps need the user's approval, tests need verify_test_stability (3 runs + fails-for-the-right-reason), audit log. strict CI-grade: no rule overrides, heals only change locators and waits, locked locators, 5 runs, a plan changed after approval blocks heals, the CI gate fails on anything unverified. Call it without argum…

ParameterTypeDescription
expectationobject
setstring
userRequeststring

start_recording

Start recording browser actions to generate test scripts later

ParameterTypeDescription
expectationobject

stop_recording

Stop recording browser actions. Returns full action log with element locators.

ParameterTypeDescription
expectationobject

recording_status

Check if recording is active and show recorded actions

ParameterTypeDescription
expectationobject

clear_recording

Clear all recorded browser actions

ParameterTypeDescription
expectationobject

planner_setup_page

Start test planning: open the application, optionally run setup steps (e.g. a login) in the browser, and load the seed test that generated tests will follow. Call once, before other planner tools

ParameterTypeDescription
explorationDepth *string
feature *stringName of the feature to create test plan for
url *stringURL of the web application to test
expectationobject
seedTeststring
setupStepsarray

planner_explore_page

Explore a page in detail: headings, input fields (with their labels, test ids and dropdown options), buttons, links and forms, as a compact inventory for writing test cases

ParameterTypeDescription
pageName *stringName of the page/section being explored
expectationobject
pageUrlstring

planner_save_plan

Save the test plan to specs/. Give it structured, as in Playwright: name, overview, suites (name, seedFile) with tests (name, target file) and steps (perform + expect per step); add the elements you found (name + locator) and any gaps. It is written as Markdown in a fixed layout. Free-form planContent is still accepted. Every saved plan is a draft ("Status: draft"): show it to the user and wait for their review. The generator refuses a draft plan; when the user approves it, call planner_approve_plan with their words.

ParameterTypeDescription
elementsarray
expectationobject
filenamestring
gapsarray
namestringTitle of the plan, e.g. "Shopping cart and checkout"
outputDirstring
overviewstringWhat the application or feature does, in a few sentences
planContentstring
suitesarray

planner_review_plan

Open a test plan as a review page in the user's browser: suites, tests, steps with their expected results, elements and gaps, with a comment box per test and Approve / Request changes buttons that write the decision into the plan. Without specFile it opens the overview of all plans in specs/ (review status, tests, generated test files, last run). Other Markdown in that folder is not a plan and is left alone. Read-only copies are saved in .selenium-ai-agent/review/ (ignored by git). Use it after planner_save_plan: ask the user to review the plan in the page, then call it again (or read the pla…

ParameterTypeDescription
expectationobject
openboolean
specFilestring

planner_approve_plan

Mark a reviewed test plan as approved, so the generator may write tests from it. Call it ONLY after the user has read the plan and explicitly approved it in the chat, and pass their words as "approval": never approve a plan yourself. The approval and the time are written into the plan. If the user asks for changes, save the changed plan with planner_save_plan (a draft again) and ask again.

ParameterTypeDescription
approval *stringThe user's own words approving the plan, quoted from the chat (e.g. "looks good, generate the tests")
specFile *stringThe plan to approve: a path, or its name in specs/ (e.g. "shopping-cart.md")
expectationobject

generator_setup_page

Initialize the test generation session and navigate to the application. When the user names no language or framework, it uses the project's own: it looks at the build files (pom.xml / build.gradle → Java with JUnit 5 or TestNG; requirements.txt / pyproject.toml → Python with pytest or unittest; *.csproj → C# with NUnit, xUnit or MSTest; package.json → JavaScript/TypeScript; *.robot → Robot Framework) and reports what it found. Only in an empty project does it use the default, Python with pytest (selenium-python-pytest, tests/test_*.py); say so in one line. When the user asks for ano…

ParameterTypeDescription
testPlan *stringTest plan content or path to test plan file. It must be approved by the user (Status: approved)
url *stringURL of the web application to test
expectationobject
frameworkstring
projectRootstring
reportingstring
skipPlanReviewboolean

generator_read_log

Retrieve the log of all actions performed during test generation session

ParameterTypeDescription
expectationobject

generator_write_test

Save generated test code to a file and update the .test-manifest.json. The manifest records everything the healer needs to run tests later: - framework, run command, config file, project root, base URL - list of all generated test files This means the healer can read the manifest and immediately know how to execute tests without the LLM having to re-analyze the project each time. The LLM can provide a custom runCommand, or let the tool suggest one based on the framework. Selenium tests are checked against Selenium's official rules for AI agents (https://www.selenium.dev/documentation/ai_ag…

ParameterTypeDescription
filename *stringFilename for the test file
testCode *stringGenerated test code
allowRuleViolationsboolean
baseUrlstring
configFilestring
expectationobject
frameworkstring
outputDirstring
projectRootstring
runCommandobject
scenariostring
skipPlanReviewboolean
specFilestring
verifyboolean

generator_write_seed

Write a seed/bootstrap test (authentication, fixtures, environment setup). Seed tests are registered in the manifest under seedTests[] and are run before the main test suite by the healer. Use this for: - Login/auth flows that save cookies or tokens - Database seeding scripts - Environment validation checks

ParameterTypeDescription
description *stringWhat this seed test does (e.g. "Login and save auth cookies")
filename *stringFilename for the seed test file
framework *stringTest framework
testCode *stringSeed test code (auth helper, fixture setup, etc.)
expectationobject
outputDirstring
projectRootstring

generator_save_spec

Save a structured markdown spec to the specs directory. Specs capture test requirements in a human-readable format before generating test code. Saved to the plans folder (specs/ in the project, or SELENIUM_MCP_SPECS_DIR) as <title-slug>.md, a draft: show it to the user, and generate tests from it only after they approve it (planner_approve_plan).

ParameterTypeDescription
content *stringMarkdown spec content
title *stringSpec title (used as filename slug)
expectationobject
outputDirstring

generator_read_spec

Read a spec file from the specs directory. Tests are only generated from an approved plan: a plan that is still a draft (Status: draft) is refused until the user has reviewed and approved it (planner_approve_plan).

ParameterTypeDescription
specFile *stringSpec or test plan to read: a path, or just its name in specs/ (e.g. "shopping-cart" or "shopping-cart.md")
expectationobject
skipPlanReviewboolean

selenium_rules_check

Scan existing tests for outdated or flaky patterns, before a migration or review: Selenium 3 APIs (find_element_by_*, findElementBy*, DesiredCapabilities, new WebDriverWait(driver, 10), TimeUnit timeouts), sleeps, implicit waits mixed with explicit ones, driver managers and driver paths, the old headless API, absolute XPath; Robot Framework Sleep / Set Selenium Speed; WebdriverIO browser.pause() and removed v10 APIs. It checks every Selenium / WebdriverIO file in Python, Java, C#, JavaScript/TypeScript, Ruby and Robot Framework against Selenium's official rules for AI agents (https://www.sele…

ParameterTypeDescription
path *stringA test folder (scanned recursively; node_modules, .venv, target, build ... are skipped) or one test file
expectationobject
frameworkstring

healer_run_tests

Execute a test command and return stdout/stderr for failure analysis. Two modes: 1. **Explicit**: Provide command + args + cwd directly (LLM has full control) 2. **Manifest**: Provide just testPath — the tool reads .test-manifest.json (created by generator_write_test) to get the run command, project root, and framework automatically. Manifest mode example: { testPath: "/path/to/project/test/specs/tc07.spec.ts" } → Finds .test-manifest.json, reads runCommand, appends --spec testPath, runs it. Explicit mode examples: { command: "npx", args: ["wdio", "run", "wdio.conf.ts", "--spec",…

ParameterTypeDescription
timeout *number
argsarray
commandstring
cwdstring
expectationobject
testPathstring

healer_debug_test

Run a single test in debug/verbose mode and return detailed output. Same as healer_run_tests but returns more output (15KB stdout, 8KB stderr) for deeper analysis. Supports both explicit mode (command + args) and manifest mode (testPath only). See healer_run_tests for details on both modes.

ParameterTypeDescription
timeout *number
argsarray
commandstring
cwdstring
expectationobject
testPathstring

healer_fix_test

Apply a fix to a test file. Creates a .bak backup before overwriting. The LLM provides the corrected code. The fix is checked against Selenium's official rules for AI agents (https://www.selenium.dev/documentation/ai_agents/). Don't fix a flaky test with a sleep or a longer timeout: find the condition that was not yet true and wait for it. A fix with an error (a sleep, a wait timeout raised above the test's old maximum, a driver path, Selenium 3 APIs, ...) is not written. The active profile (agent_profile) sets the heal policy. Each fix is classified as locator, wait, assertion, removed / ad…

ParameterTypeDescription
fixDescription *stringDescription of what was fixed
fixedCode *stringThe corrected test code
testPath *stringAbsolute path to the test file to fix
allowRuleViolationsboolean
expectationobject
frameworkstring
userApprovalstring
verifyboolean

verify_test_stability

Prove a test is deterministic before it counts as done: no LLM involved, only test runs. 1. Stability: runs the test N times in a row (the profile's stabilityRuns). One red run means the test is flaky (or failing): it is not accepted. 2. Fails for the right reason: copies of the test with one expected value changed (an assertion mutant each) must go red. A mutant that stays green shows an assertion that checks nothing. Skipped for Java and C# (use PIT / Stryker.NET). The result is stored in .test-manifest.json with the hash of the file: editing or healing the test makes it unverified agai…

ParameterTypeDescription
testPath *stringAbsolute path to the test file (it must be in .test-manifest.json: written with generator_write_test)
timeout *number
expectationobject
failCheckboolean
runsnumber

browser_generate_locator

Generate a robust locator for an element described in plain words, e.g. "search box" or "the Add to Cart button of the Mechanical Keyboard". Matches text, label, placeholder, test id, element kind and the surrounding content; returns ready-to-paste locators for JavaScript, Python, Java, C# and Robot Framework. For elements in shadow DOM WebDriver cannot reach (Salesforce Lightning), the locators call a small helper file, returned once with the first such locator: save it next to the tests

ParameterTypeDescription
elementDescription *stringDescription of the element to find a locator for
expectationobject

healer_inspect_page

Inspect the current page and compare expected locators against actual elements. Use after a test failure to understand UI drift before applying a fix. Reports: - Found elements (locator still works) - Missing elements (locator broken, may need update) - Suggested updated locators based on element discovery

ParameterTypeDescription
locators *arrayExpected locators to validate against the live page
expectationobject

analyzer_setup

Initialize regression analysis session with product URL and business context

ParameterTypeDescription
productName *stringName of the product
riskAppetite *string
url *stringBase URL of the product to analyze
compliancearray
criticalFlowsarray
expectationobject
outputDirstring

analyzer_import_context

Import additional context from local files, inline text, or URLs to enrich the analysis

ParameterTypeDescription
contextType *string
source *stringFile path, inline text content, or URL depending on sourceType
sourceType *stringType of source: 'file' (local file), 'text' (inline text), 'url' (web page)
descriptionstring
expectationobject

analyzer_scan_product

Explore the product using both process walking (from imported context) and page scanning

ParameterTypeDescription
maxPages *number
scanDepth *string
expectationobject
focusAreasarray

analyzer_build_risk_profile

Build comprehensive risk profile from discovered features and context

ParameterTypeDescription
includePipelineConfig *boolean
includeRecommendations *boolean
expectationobject

analyzer_save_profile

Save the completed risk profile to a file

ParameterTypeDescription
outputFormat *string
expectationobject
filenamestring
outputDirstring

analyzer_generate_documentation

Generate a comprehensive product discovery document with screenshots - serves as input for the Planner agent

ParameterTypeDescription
includeRiskSummary *boolean
includeScreenshots *boolean
outputFormat *string
expectationobject
outputFilenamestring