Skip to content

feat: add Internet Explorer mode support for Edge browser #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -121,16 +121,20 @@ 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:
- `headless`: Run browser in headless mode
- 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",
Expand All @@ -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"]
}
}
}
```

Comment on lines +151 to +164
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Tighten the Edge IE mode example; clarify args and env var usage.

  • Chromium flags like --disable-web-security may not be honored under IE mode. Prefer showing an Edge-relevant flag (e.g., --inprivate) or omit arguments to avoid implying support.
  • Include the EDGE_PATH example to help users whose Edge isn’t in a default location.
  • Explicitly state that headless is ignored in IE mode.
-Edge with Internet Explorer mode (most important feature):
+Edge with Internet Explorer mode:
 ```json
 {
   "tool": "start_browser",
   "parameters": {
     "browser": "edge",
     "options": {
       "ieMode": true,
-      "arguments": ["--disable-web-security"]
+      "arguments": ["--inprivate"]
     }
   }
 }

+Prerequisites:
+- Windows-only. Ensure IE Mode is enabled for Edge via enterprise policy/registry.
+- IEDriverServer should be available on PATH.
+- If Edge is not in a default location, set the environment variable before launching:

    • Windows PowerShell: $env:EDGE_PATH="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
      +- Headless is not supported in IE mode; any headless option will be ignored.

---

🌐 Web query:

```web
In Selenium WebDriver for Node.js (selenium-webdriver package), what is the correct API to pass command-line arguments to Edge when using InternetExplorer Options with `setEdgeChromium(true)` (IE mode)? Is `addBrowserCommandSwitches` available on `selenium-webdriver/ie` Options, or should `ie.edgeargs` be set via capabilities?

💡 Result:

Short answer

  • addBrowserCommandSwitches exists on selenium-webdriver/ie Options (it sets ie.browserCommandLineSwitches) — but it is for launching Internet Explorer (CreateProcess API) and is not an API to pass command‑line args into the Chromium Edge process when using IE‑mode.
  • There is no documented ie.edgeargs option on selenium-webdriver/ie Options. If you need to pass arguments to Edge itself, do that with EdgeOptions (ms:edgeOptions / EdgeOptions.args) when starting Edge with EdgeDriver, or use a wrapper/executable specified via the IE option that points Edge to a binary launched with the desired flags. The IE driver supports ie.edgepath/ie.edgechromium to attach to Edge, but not a direct ie.edgeargs option. (selenium.dev, learn.microsoft.com)

Details / recommended approaches

  • The Node.js IE Options class exposes addBrowserCommandSwitches(...) (and the deprecated addArguments(...)) which set the IE capability ie.browserCommandLineSwitches. Those switches are intended for Internet Explorer itself (used when forceCreateProcessApi is enabled). (selenium.dev)
  • The IE/IEDriver support for automating IE‑mode in Edge is limited to flags such as ie.edgechromium (attachToEdgeChrome) and ie.edgepath (Edge executable path). Microsoft’s IE‑mode docs show AttachToEdgeChrome / EdgeExecutablePath but don’t document an ie.edgeargs capability. (learn.microsoft.com)
  • Edge/Chromium accepts command‑line args via ms:edgeOptions (EdgeOptions.args / ms:edgeOptions.args). That is the documented place to pass Chromium flags — but that applies when you launch Edge with EdgeDriver, not when IE Driver launches Edge in IE‑mode. If you can run Edge directly under EdgeDriver, use EdgeOptions to pass args. (learn.microsoft.com)

Workarounds if you must use IEDriver + IE‑mode and need Edge args

  • Put a small wrapper executable or script as the value for the IE option that points to Edge (ie.edgepath / EdgeExecutablePath) which launches msedge.exe with the desired command‑line switches.
  • Or, if possible, switch to launching Edge directly with EdgeDriver and supply ms:edgeOptions.args via EdgeOptions (clean and supported).
  • If you believe you need native support for passing Edge args via IEDriver, consider filing an issue with the IEDriver / Selenium projects or checking the IEDriver release notes for later additions.

If you want, tell me which exact flags you need to pass and whether you must use IE‑mode via IEDriver or can launch Edge directly — I can show the exact code for the appropriate approach (IE Options + wrapper or EdgeOptions with ms:edgeOptions.args).

Citations:


Remove unsupported arguments in IE mode; clarify no Edge flags are passed

The IE-mode snippet in README.md currently suggests passing Chromium flags via the IE Options arguments field—but IEDriver’s IE-mode support (setEdgeChromium/ie.edgechromium) does not honor any arguments or ie.edgeargs. Instead:

• Remove the "arguments": […] line entirely (or replace it with a comment stating that args are ignored).
• If you truly need to launch Edge in IE-mode with extra flags (e.g. --inprivate), you must either:
– Launch Edge directly via EdgeDriver with EdgeOptions (ms:edgeOptions.args), or
– Point ie.edgepath (EdgeExecutablePath) to a wrapper script/executable that invokes Edge with the desired switches.
• Add an EDGE_PATH example for non-default installs.
• Clearly note that headless is ignored in IE-mode and that IE-mode requires Windows + enterprise policy/registry.

Pinpointed location:
• README.md, lines 151–164

Suggested diff:

 Edge with Internet Explorer mode:
 {
   "tool": "start_browser",
   "parameters": {
     "browser": "edge",
     "options": {
       "ieMode": true,
-      "arguments": ["--disable-web-security"]
+      // IE-mode via IEDriver does not support Chromium args
     }
   }
 }
 
 Prerequisites:
 - Windows only; IE Mode enabled for Edge via enterprise policy/registry.
 - IEDriverServer on PATH.
 - If Edge isn’t in the default location, set:
     PowerShell: $env:EDGE_PATH="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"
 - Headless is ignored in IE mode.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Edge with Internet Explorer mode (most important feature):
```json
{
"tool": "start_browser",
"parameters": {
"browser": "edge",
"options": {
"ieMode": true,
"arguments": ["--disable-web-security"]
}
}
}
```
Edge with Internet Explorer mode:
{
"tool": "start_browser",
"parameters": {
"browser": "edge",
"options": {
"ieMode": true,
// IE-mode via IEDriver does not support Chromium args
}
}
}
🤖 Prompt for AI Agents
In README.md around lines 151 to 164, the IE-mode example incorrectly shows
passing Chromium flags via the IE Options "arguments" field; remove the
"arguments" line (or replace it with a one-line comment that IE-mode ignores
arguments/ie.edgeargs), add guidance that to pass Edge flags you must either
launch Edge directly via EdgeDriver with EdgeOptions (ms:edgeOptions.args) or
point ie.edgepath to a wrapper/executable that launches Edge with the desired
switches, include an example/mention of EDGE_PATH for non-default Edge installs,
and add a clear note that headless is ignored in IE-mode and that IE-mode
requires Windows plus enterprise policy/registry configuration.

### navigate
Navigates to a URL.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
44 changes: 33 additions & 11 deletions src/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 {
Comment on lines +88 to +105
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

IE mode branch: add OS/headless guards; verify argument API.

  • IE mode is Windows-only. Add a guard to fail fast on non-Windows.
  • Headless is not supported; explicitly ignore or reject headless when ieMode is true.
  • Double-check whether addBrowserCommandSwitches is the correct API for passing Edge args in IE mode; some setups require setting the ie.edgeargs capability instead.

Apply these safety checks:

                 case 'edge': {
-                    if (options.ieMode) {
+                    if (options.ieMode) {
+                        if (process.platform !== 'win32') {
+                            throw new Error('Edge IE mode is only supported on Windows.');
+                        }
+                        if (options.headless) {
+                            console.warn('Ignoring headless option: IE mode does not support headless.');
+                        }
                         // 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));
-                        }
+                        // NOTE: Verify the correct API for passing Edge args in IE mode.
+                        // Some environments require setting 'ie.edgeargs' capability.
+                        if (options.arguments?.length) {
+                            try {
+                                // If supported by current selenium-webdriver version:
+                                options.arguments.forEach(arg => ieOptions.addBrowserCommandSwitches(arg));
+                            } catch {
+                                // Fallback: set capability used by IEDriver to pass args to Edge
+                                ieOptions.set('ie.edgeargs', options.arguments);
+                            }
+                        }
                         driver = await builder
                             .forBrowser('internet explorer')
                             .setIeOptions(ieOptions)
                             .build();
                     } else {

🌐 Web query:

For Node selenium-webdriver IE Options, what is the supported way to supply Edge command-line args when `setEdgeChromium(true)` is used? Is `addBrowserCommandSwitches` the correct method name, or should `ie.edgeargs` be provided as a capability?

💡 Result:

Short answer: neither. addBrowserCommandSwitches (aka addArguments) is for Internet Explorer (when using the CreateProcess API) and won’t set Chromium/Edge command‑line flags. There is no documented selenium capability named ie.edgeargs. If you need to pass command‑line args to Edge, do it via EdgeOptions (ms:edgeOptions / EdgeOptions.args or webviewOptions.additionalBrowserArguments for WebView2) when launching EdgeDriver — you cannot inject normal Edge CLI args through the IE Options API used by setEdgeChromium(true).

Why:

  • The IE Options API exposes addBrowserCommandSwitches / ie.browserCommandLineSwitches for IE process switches (used with forceCreateProcessApi). (selenium.dev)
  • The IE‑mode/IEDriver documentation only documents enabling attachToEdgeChrome (ie.edgechromium / ie.edgepath) to tell IEDriver to start Edge in IE mode; it does not document passing Edge CLI args via se:ieOptions. (learn.microsoft.com, selenium.dev)
  • Edge/Chromium flags are supported via EdgeOptions (ms:edgeOptions args or webviewOptions.additionalBrowserArguments for WebView2). Use EdgeOptions.addArguments or set the ms:edgeOptions.args capability when launching EdgeDriver. (selenium.dev, learn.microsoft.com)

What to do instead

  • If you control starting Edge yourself: launch Edge via EdgeDriver and pass args with EdgeOptions (Node example):
  • If you must use IEDriver.attachToEdgeChrome (IE mode): there is no supported IE Options setting to pass arbitrary Edge CLI switches — you’ll need an alternate approach (launch Edge with desired args yourself and attach, use EdgeDriver, or configure the Edge/WebView2 runtime via its own configuration).

If you want, tell me which exact flags you need to set and whether you're using IEDriver (IE mode) or EdgeDriver — I can show the exact Node code (EdgeOptions vs IE Options) and a recommended workaround if you must stay on IE mode.

Citations:


Enforce Windows-only and drop unsupported Edge args in IE mode

  • Fail fast on non-Windows platforms
  • Warn and ignore headless when ieMode is true
  • Drop the attempt to pass options.arguments via IEOptions—Edge CLI flags aren’t supported through the IE Options API
                 case 'edge': {
-                    if (options.ieMode) {
+                    if (options.ieMode) {
+                        if (process.platform !== 'win32') {
+                            throw new Error('IE mode is only supported on Windows.');
+                        }
+                        if (options.headless) {
+                            console.warn('Ignoring headless option: IE mode does not support headless.');
+                        }
                         // 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);
                         }
-                        // NOTE: Verify the correct API for passing Edge args in IE mode.
-                        // Some environments require setting 'ie.edgeargs' capability.
-                        if (options.arguments?.length) {
-                            try {
-                                // If supported by current selenium-webdriver version:
-                                options.arguments.forEach(arg => ieOptions.addBrowserCommandSwitches(arg));
-                            } catch {
-                                // Fallback: set capability used by IEDriver to pass args to Edge
-                                ieOptions.set('ie.edgeargs', options.arguments);
-                            }
-                        }
+                        if (options.arguments?.length) {
+                            console.warn(
+                                'Edge CLI arguments are not supported via IEOptions and will be ignored. ' +
+                                'To pass Edge flags, launch EdgeDriver directly with EdgeOptions.'
+                            );
+                        }
                         driver = await builder
                             .forBrowser('internet explorer')
                             .setIeOptions(ieOptions)
                             .build();
                     } else {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 {
case 'edge': {
if (options.ieMode) {
if (process.platform !== 'win32') {
throw new Error('IE mode is only supported on Windows.');
}
if (options.headless) {
console.warn('Ignoring headless option: IE mode does not support headless.');
}
// 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?.length) {
console.warn(
'Edge CLI arguments are not supported via IEOptions and will be ignored. ' +
'To pass Edge flags, launch EdgeDriver directly with EdgeOptions.'
);
}
driver = await builder
.forBrowser('internet explorer')
.setIeOptions(ieOptions)
.build();
} else {
// ...
🤖 Prompt for AI Agents
In src/lib/server.js around lines 88 to 105, enforce Windows-only for IE mode by
checking process.platform and throwing an error if not 'win32', remove the loop
that attempts to pass options.arguments into IEOptions (Edge CLI flags are
unsupported via the IEOptions API) and instead log a warning when
options.arguments is present, and if options.headless (or any headless flag) is
set while ieMode is true log a warning that headless is ignored; keep the
existing IEOptions configuration for Edge Chromium attachment and protected
mode/zoom settings but fail fast on non-Windows, drop adding browser CLI
switches to IEOptions, and emit warnings for ignored headless/arguments.

// 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': {
Expand Down