ScreenshotNeo

BlogHow-to

How to Run Selenium Tests on Internet Explorer and Microsoft Edge

Choose Selenium 4 for current Edge or Internet Explorer Driver for legacy sites in Edge IE mode, with setup steps, runnable code, and troubleshooting.

By the ScreenshotNeo team4 October 20269 min read

Direct answer: For ordinary tests in current Chromium-based Microsoft Edge, use Selenium 4 with Microsoft Edge WebDriver and Selenium’s Edge driver classes. For a legacy site that needs Internet Explorer behavior, run Microsoft Edge in IE mode with Internet Explorer Driver (IEDriver) and Internet Explorer options. Microsoft’s IE-mode guide requires IEDriver 4.0.0.0 or later. Standalone Internet Explorer is retired as a modern Selenium target.

These are different automation paths. First decide whether the test is meant to exercise current Edge or legacy IE compatibility; then install and configure the matching driver. Microsoft’s Edge WebDriver guide covers current Edge, and its IE-mode automation guide covers legacy behavior.

1. Choose the right browser path

Decision Current Edge Legacy IE behavior
What runs Chromium-based Microsoft Edge IE mode in Microsoft Edge
Selenium API Edge driver classes Internet Explorer driver and options
Driver Microsoft Edge WebDriver matching the installed Edge version IEDriver 4.0.0.0 or later per Microsoft’s guide
Use it when Testing standard Edge behavior A legacy site depends on IE compatibility behavior
Main caution Use Selenium 4; Selenium 3 is not Microsoft’s supported current Edge path IE mode may require enterprise configuration; standalone IE is retired

Selenium states that official support for standalone Internet Explorer ended in June 2022. Its IE driver documentation still describes running Microsoft Edge in IE Compatibility Mode. Microsoft says IE support ended on June 15, 2022 for certain Windows versions and identifies IE mode as the compatibility route for organizations that still need legacy behavior. An Enterprise Site List may be part of that setup. See Selenium’s IE-specific documentation and Microsoft Support’s IE mode overview.

2. Run a test in current Microsoft Edge

Install and configure

  1. Use Selenium 4 and install the binding for your language.
  2. Install Microsoft Edge WebDriver for the Edge version on the test machine. Follow Microsoft’s current Edge WebDriver instructions for driver availability and version matching.
  3. Make the driver available to Selenium through the documented setup for your binding and environment.
  4. Launch an Edge session with the Edge-specific Selenium class, navigate to the page, assert the behavior, and quit the session.

Here is a complete Python pattern. It assumes Selenium 4 is installed and Edge WebDriver is available to the environment:

from selenium import webdriver
from selenium.webdriver.common.by import By

options = webdriver.EdgeOptions()
driver = webdriver.Edge(options=options)
try:
    driver.get("https://example.com")
    heading = driver.find_element(By.TAG_NAME, "h1")
    assert heading.text.strip(), "Expected a non-empty page heading"
finally:
    driver.quit()

Use the current Edge API and driver path documented by Microsoft. Do not use the old EdgeHTML-era Microsoft WebDriver for Chromium-based Edge, and do not use Selenium 3 for this current Edge path. Microsoft’s guide distinguishes current Edge from the older EdgeHTML browser.

3. Run a legacy site in Edge IE mode

Prerequisites

  • A Windows machine with Microsoft Edge and the target IE-mode configuration.
  • Selenium 4 in the language binding you use.
  • IEDriver 4.0.0.0 or later, as required by Microsoft’s IE-mode guide. Put the driver executable on PATH or configure its location using the setup for your binding.
  • If the site is managed through an Enterprise Site List, ensure the test machine has the appropriate organization configuration. Selenium launching a browser does not itself configure the site’s IE-mode policy.

Python example

This follows Microsoft’s documented launch pattern. The Edge executable path varies by machine; update it to the installed msedge.exe location when needed.

from selenium import webdriver
from selenium.webdriver.common.by import By

ie_options = webdriver.IeOptions()
ie_options.attach_to_edge_chrome = True
ie_options.edge_executable_path = (
    r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
)

driver = webdriver.Ie(options=ie_options)
try:
    driver.get("https://example.com")
    heading = driver.find_element(By.TAG_NAME, "h1")
    assert heading.text.strip(), "Expected a non-empty page heading"
finally:
    driver.quit()

Java example

Install Selenium 4 and make IEDriver available to the Java process. Set the executable path for your environment, then configure IE options to attach to Edge as described in Microsoft’s guide.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;
import org.openqa.selenium.By;

public class IeModeSmokeTest {
    public static void main(String[] args) {
        System.setProperty("webdriver.ie.driver", "C:\\drivers\\IEDriverServer.exe");
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdge等(true);
        options.withEdgeExecutablePath(
            "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");

        WebDriver driver = new InternetExplorerDriver(options);
        try {
            driver.get("https://example.com");
            String heading = driver.findElement(By.tagName("h1")).getText();
            if (heading.trim().isEmpty()) throw new AssertionError("Expected heading");
        } finally {
            driver.quit();
        }
    }
}

Java API note: Selenium binding method names can vary by release. Use Microsoft’s current Java sample and your installed Selenium API for the attach-to-Edge and executable-path option names; do not copy an option name that your binding does not expose.

C# example

With Selenium 4 and IEDriver configured for the process, create Internet Explorer options, enable attachment to Edge, optionally provide the Edge binary path, and always dispose the session.

using OpenQA.Selenium;
using OpenQA.Selenium.IE;

var options = new InternetExplorerOptions
{
    AttachToEdgeChrome = true,
    EdgeExecutablePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
};

IWebDriver driver = new InternetExplorerDriver(options);
try
{
    driver.Navigate().GoToUrl("https://example.com");
    var heading = driver.FindElement(By.TagName("h1")).Text;
    if (string.IsNullOrWhiteSpace(heading))
        throw new InvalidOperationException("Expected a non-empty heading");
}
finally
{
    driver.Quit();
}

Confirm the exact option property names against the Selenium .NET version and Microsoft’s maintained IE-mode example before adopting this in a project.

JavaScript example

Install the Selenium JavaScript package and configure IEDriver for the runtime. Microsoft’s IE-mode guidance includes a JavaScript launch example; the exact builder and capability syntax should follow the package version in use.

const { Builder, By } = require('selenium-webdriver');
const ie = require('selenium-webdriver/ie');

(async function runIeModeTest() {
  const options = new ie.Options();
  options.attachToEdgeChrome(true);
  options.withEdgeExecutablePath(
    'C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe'
  );

  const driver = await new Builder()
    .forBrowser('internet explorer')
    .setIEOptions(options)
    .build();
  try {
    await driver.get('https://example.com');
    const heading = await driver.findElement(By.css('h1')).getText();
    if (!heading.trim()) throw new Error('Expected a non-empty heading');
  } finally {
    await driver.quit();
  }
})();

Use the IE options and builder methods provided by the installed Selenium JavaScript binding and Microsoft’s current sample. IE-mode APIs are legacy-specific and may not match ordinary Edge’s builder configuration.

4. Configure IE-mode attachment carefully

  • Attach to Edge: Microsoft’s Python sample sets attach_to_edge_chrome to true. The corresponding option exists in the language examples in Microsoft’s guide.
  • Edge executable: Set the path to msedge.exe when required by the environment. The path in examples is not universal; 32-bit and 64-bit Windows installations can differ.
  • Driver discovery: Place IEDriver on PATH or configure its path through the language/runtime mechanism. Confirm the process can execute it.
  • Automatic attachment behavior: Selenium documents that from IEDriver 4.5.0, explicit attach and executable-path parameters may not be needed when Internet Explorer is absent. If both IE and Edge are present, only the attach setting may be needed. Treat this as environment-dependent and verify with the installed driver.
  • Close the session: Call quit() even after assertion failures so driver processes do not accumulate.

5. Legacy Windows configuration checks

Some Internet Explorer driver requirements apply to legacy Windows and IE setups. They are not universal fixes for every Edge IE-mode installation, so check applicability before changing machine policy:

  • Selenium recommends the 32-bit IE driver because the 64-bit driver has known limitations.
  • The legacy IE Driver Server documentation describes consistent Protected Mode settings across Internet Explorer security zones and an IE 11 registry setting.
  • Enterprise IE mode may depend on organization-managed configuration, including an Enterprise Site List.

Use Selenium’s IE Driver Server configuration page for the legacy requirements, and Microsoft’s IE-mode guide for the Edge attachment path. Avoid applying registry or security-zone changes blindly to managed machines.

6. Common errors and fixes

Symptom Likely cause What to check
Session cannot start or driver executable is missing IEDriver or Edge WebDriver is not discoverable Confirm the correct driver is on PATH or configured in the runtime, and that the executable can run.
Current Edge launches incorrectly or fails at startup Wrong browser path, old EdgeHTML driver, or unsupported Selenium 3 setup Use Selenium 4, Chromium Edge WebDriver, and Microsoft’s current Edge instructions.
IE-mode session opens the wrong browser behavior IE attachment option is absent, IE mode is not configured for the target site, or site policy is missing Set the attach option and verify the machine’s IE-mode/Enterprise Site List configuration.
IEDriver cannot find Edge Edge is installed in a different location or explicit path is needed Set the correct msedge.exe path using the binding’s IE options.
Legacy IE driver hangs during startup or interactions Relevant legacy IE configuration is inconsistent For applicable IE setups, review Protected Mode consistency and the documented IE 11 registry setting in Selenium’s driver guidance.
Element lookup fails although the page appears loaded The page is still navigating, content is delayed, or the locator does not match the rendered DOM Use an explicit wait for the expected condition, check the locator in the target mode, and distinguish a real application failure from a timing issue.
Driver processes remain after a failed test Cleanup was skipped on an exception Put driver.quit() in a finally block.

7. Reliability, performance, and maintenance

  • Keep the browser and driver aligned: For current Edge, follow Microsoft’s driver version guidance as Edge updates. Treat browser/driver drift as an environment issue to resolve before investigating application behavior.
  • Separate modern and legacy coverage: Keep standard Chromium Edge tests on Edge WebDriver. Reserve IE-mode tests for pages and behaviors that actually require compatibility mode.
  • Control the test environment: IE-mode policy and executable paths can differ across developer machines and CI agents. Document prerequisites and provision them consistently.
  • Wait for state, not arbitrary time: Prefer Selenium waits for a specific element or condition over fixed sleeps when the test requires the page to finish a task.
  • Ensure cleanup: Always quit drivers, including when assertions fail. This improves repeatability and avoids stale browser sessions.
  • Plan for legacy risk: IE mode is a compatibility facility, and standalone IE support is retired. Keep legacy tests narrowly scoped and verify the target organization’s supported configuration.
  • Cost: These local Selenium paths use browser and driver software; the dossier identifies no required paid service or hardware for the setup. CI infrastructure and maintenance costs depend on the environment and are not quantified by the cited documentation.

8. Or skip the browser setup

If the goal is to capture a page image or PDF for documentation, review, or an AI workflow, you may not need to maintain a Selenium browser session. ScreenshotNeo is a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://example.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie banners and consent prompts are accepted, and more than 60 known consent platforms, newsletter popups, and chat widgets are removed before the shot; each step can be turned off.
  • Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers report the page verdict and billing status.
  • An MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
  • The Free plan includes 1,000 shots per month with no card. Paid plans start at $5 for 3,000 shots. Every feature is on every plan.

Create a free ScreenshotNeo account for 1,000 screenshots a month, with no card.

9. FAQ

Can Selenium automate standalone Internet Explorer?

Selenium officially ended standalone Internet Explorer support in June 2022. For legacy IE behavior, use the documented Edge IE-mode route where it fits your environment.

Does an IE-mode test use Edge WebDriver?

Microsoft’s IE-mode automation guide uses Internet Explorer Driver with IE options that attach the driver to Edge.

Do I always need to set the Edge executable path?

No. Selenium documents configurations where newer IEDriver versions can detect Edge or need only the attach option. Confirm behavior for your driver and machine.

Should all Edge tests run in IE mode?

No. Use ordinary Edge automation for current Edge behavior. Use IE mode only when the test must exercise legacy compatibility behavior.