-
Notifications
You must be signed in to change notification settings - Fork 61
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+88
to
+105
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainIE mode branch: add OS/headless guards; verify argument API.
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:
💡 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:
What to do instead
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
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
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// 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': { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
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.
--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.EDGE_PATH
example to help users whose Edge isn’t in a default location.+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:
$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.💡 Result:
Short answer
Details / recommended approaches
Workarounds if you must use IEDriver + IE‑mode and need Edge args
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 passedThe 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 anyarguments
orie.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:
📝 Committable suggestion
🤖 Prompt for AI Agents