diff --git a/README.md b/README.md index 9d05b59..e8556a1 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ A Model Context Protocol (MCP) server implementation for Selenium WebDriver, ena - Chrome - Firefox -- MS Edge +- MS Edge (with Internet Explorer mode support) ## Use with Goose @@ -121,7 +121,7 @@ Launches a browser session. **Parameters:** - `browser` (required): Browser to launch - Type: string - - Enum: ["chrome", "firefox"] + - Enum: ["chrome", "firefox", "edge"] - `options`: Browser configuration options - Type: object - Properties: @@ -129,8 +129,12 @@ Launches a browser session. - Type: boolean - `arguments`: Additional browser arguments - Type: array of strings + - `ieMode`: Enable Internet Explorer mode for Edge (Edge only) + - Type: boolean -**Example:** +**Examples:** + +Chrome browser: ```json { "tool": "start_browser", @@ -144,6 +148,20 @@ Launches a browser session. } ``` +Edge with Internet Explorer mode (most important feature): +```json +{ + "tool": "start_browser", + "parameters": { + "browser": "edge", + "options": { + "ieMode": true, + "arguments": ["--disable-web-security"] + } + } +} +``` + ### navigate Navigates to a URL. diff --git a/package.json b/package.json index 58e5294..20c1135 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@angiejones/mcp-selenium", - "version": "0.1.21", + "version": "0.1.22", "description": "Selenium WebDriver MCP Server", "type": "module", "main": "src/lib/server.js", diff --git a/src/lib/server.js b/src/lib/server.js index 78d7514..b5d1799 100755 --- a/src/lib/server.js +++ b/src/lib/server.js @@ -8,6 +8,7 @@ const { Builder, By, Key, until, Actions } = pkg; import { Options as ChromeOptions } from 'selenium-webdriver/chrome.js'; import { Options as FirefoxOptions } from 'selenium-webdriver/firefox.js'; import { Options as EdgeOptions } from 'selenium-webdriver/edge.js'; +import { Options as IEOptions } from 'selenium-webdriver/ie.js'; // Create an MCP server @@ -46,7 +47,8 @@ const getLocator = (by, value) => { // Common schemas const browserOptionsSchema = z.object({ headless: z.boolean().optional().describe("Run browser in headless mode"), - arguments: z.array(z.string()).optional().describe("Additional browser arguments") + arguments: z.array(z.string()).optional().describe("Additional browser arguments"), + ieMode: z.boolean().optional().describe("Enable Internet Explorer mode for Edge (Edge only)") }).optional(); const locatorSchema = { @@ -83,17 +85,37 @@ server.tool( break; } case 'edge': { - const edgeOptions = new EdgeOptions(); - if (options.headless) { - edgeOptions.addArguments('--headless=new'); - } - if (options.arguments) { - options.arguments.forEach(arg => edgeOptions.addArguments(arg)); + if (options.ieMode) { + // For IE mode, use IE driver with Edge Chromium attachment + const ieOptions = new IEOptions(); + ieOptions.setEdgeChromium(true); + // Fix Protected Mode settings error + ieOptions.introduceFlakinessByIgnoringProtectedModeSettings(true); + ieOptions.ignoreZoomSetting(true); + if (process.env.EDGE_PATH) { + ieOptions.setEdgePath(process.env.EDGE_PATH); + } + if (options.arguments) { + options.arguments.forEach(arg => ieOptions.addBrowserCommandSwitches(arg)); + } + driver = await builder + .forBrowser('internet explorer') + .setIeOptions(ieOptions) + .build(); + } else { + // Regular Edge browser + const edgeOptions = new EdgeOptions(); + if (options.headless) { + edgeOptions.addArguments('--headless=new'); + } + if (options.arguments) { + options.arguments.forEach(arg => edgeOptions.addArguments(arg)); + } + driver = await builder + .forBrowser('edge') + .setEdgeOptions(edgeOptions) + .build(); } - driver = await builder - .forBrowser('edge') - .setEdgeOptions(edgeOptions) - .build(); break; } case 'firefox': {