sodcalculator

10 Tech How-To

Selenium Tests on IE & Edge: Step-by-Step

Guide 10-23379 · Updated · Step by step

This guide walks you through configuring and running Selenium tests on legacy Internet Explorer (IE) and modern Microsoft Edge browsers. You’ll learn the required drivers, capability settings, and common pitfalls so your automation works reliably on both engines.

What You’ll Need

  • A working Selenium setup (Python, Java, C#, etc.) with the Selenium WebDriver library installed.
  • Internet Explorer 11 installed (IE mode in Edge is also covered).
  • Microsoft Edge (Chromium-based, version 79 or later) installed.
  • The appropriate WebDriver executables: IEDriverServer.exe for IE and msedgedriver.exe for Edge.
  • Administrator rights on Windows for IE configuration changes.

Step-by-Step

  1. Download the correct drivers.
    • For IE: get IEDriverServer from the Selenium project (choose the 32-bit or 64-bit version matching your OS).
    • For Edge: download msedgedriver from the Microsoft Edge Driver page. Match the driver version to your Edge browser version (go to edge://settings/help to find it).
  2. Place drivers in your PATH or specify their location. Add the driver folder to your system PATH, or pass the path directly when creating the driver instance.
  3. Configure Internet Explorer for Selenium.
    • Open Internet Options → Security tab.
    • For each zone (Internet, Local intranet, Trusted sites, Restricted sites), click Custom level and scroll to Enable Protected Mode. Ensure it is either enabled or disabled consistently across all zones. The recommended setting is to enable it for all zones.
    • Set the zoom level to 100% (IE only). Go to View → Zoom and select 100%, or set the registry value HKCU\Software\Microsoft\Internet Explorer\Zoom to 100000.
    • For 64-bit Windows, if you use the 32-bit IEDriverServer, you may need to disable Enhanced Protected Mode (Internet Options → Advanced tab).
  4. Create the IE WebDriver instance. In your test code, set the desired capabilities. For Java (similar in other languages):
    DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
    caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    WebDriver driver = new InternetExplorerDriver(caps);

    The INTRODUCE_FLAKINESS capability is often needed when the test URL and the browser’s security zones differ.

  5. Create the Edge WebDriver instance. For Chromium Edge:
    System.setProperty("webdriver.edge.driver", "path/to/msedgedriver.exe");
    WebDriver driver = new EdgeDriver();

    No extra capabilities are usually required. For legacy Edge (EdgeHTML), you would use EdgeDriver with the older MicrosoftWebDriver, but that is deprecated.

  6. Write and run your tests. Use your standard Selenium test structure. For IE, be aware that it is slower than modern browsers, so increase implicit wait times (e.g., 10 seconds). For Edge, treat it like Chrome – it should work with the same code.
  7. Handle IE mode in Edge (optional). If you must test legacy IE-only sites, you can configure Edge to use IE mode. In Edge, go to edge://flags and enable IE mode (or set it via group policy). Then you can use the IEDriverServer with a special capability to attach to Edge in IE mode – but this is complex. A simpler approach is to use the ie.edgechromium capability (requires IEDriverServer 3.150.1 or later) and point to the Edge executable.

Common Mistakes

  • Protected Mode inconsistency: Having Protected Mode enabled in some zones and disabled in others causes a NoSuchWindowException or a failure to start.
  • Zoom not at 100%: IE will throw a NoSuchElementException if zoom is not 100% because coordinates are off.
  • Driver version mismatch: Using an old IEDriverServer with a newer IE, or a mismatched msedgedriver version, leads to errors like SessionNotCreatedException.
  • Forgetting to set the driver path: If the driver is not in PATH, you’ll get a WebDriverException saying the driver executable does not exist.
  • Using 32-bit vs 64-bit incorrectly: If you use a 32-bit IEDriverServer on 64-bit Windows, you may need to disable Enhanced Protected Mode, otherwise it fails.

Tips

  • Always use the latest stable version of IEDriverServer (3.150.1 or later) for better compatibility with Windows 10/11.
  • For Edge, you can use the same WebDriver code as Chrome – just change the driver class and executable.
  • Set a generous page load timeout for IE (e.g., 60 seconds) because it loads slowly.
  • Use InternetExplorerOptions instead of deprecated DesiredCapabilities in newer Selenium versions (4.x).
  • Run IE tests in a separate environment or VM to avoid interfering with your regular browsing.

Troubleshooting

  • Driver fails to start: Check that the driver is not blocked by Windows Defender – right-click the driver file, go to Properties, and unblock if needed. Also ensure the driver is not corrupted.
  • IE opens but then closes immediately: This usually indicates a Protected Mode mismatch. Re-check all zones and set them identically.
  • Elements not found in IE: Ensure zoom is 100% and that the page is fully loaded. Try adding a wait: new WebDriverWait(driver, 10).until(ExpectedConditions.presenceOfElementLocated(By.id(...))).
  • Edge driver error: “Unable to find matching capabilities”: Update msedgedriver to match your Edge version exactly. Use the --version command on Edge to check.
  • Slow execution in IE: Reduce the number of implicit waits, but keep a small wait for dynamic content. Also disable animations in Windows for faster rendering.

Frequently Asked Questions

Can I run Selenium tests on Internet Explorer 11 on Windows 11?

Yes, but IE11 is out of support. You can enable IE mode in Edge and use the IEDriverServer with the ie.edgechromium capability to target Edge in IE mode.

Do I need a separate driver for Edge and IE?

Yes. IE requires IEDriverServer.exe, while Edge (Chromium) requires msedgedriver.exe. They are not interchangeable.

Why does my IE test fail with a ‘NoSuchWindow’ error?

This is almost always due to Protected Mode settings being different across security zones. Make them consistent and restart the browser.

Is Selenium support for IE discontinued?

Selenium 4 still supports IE, but it is considered legacy. The Selenium project recommends using Edge in IE mode for testing legacy sites.

Can I run Edge tests in headless mode?

Yes, Chromium Edge supports headless mode. Set the --headless argument via ChromeOptions (or EdgeOptions) before creating the driver.

How do I set the browser zoom to 100% programmatically for IE?

You can set the registry key HKCU\Software\Microsoft\Internet Explorer\Zoom to 100000 (decimal) before starting the driver. Alternatively, use the browser’s zoom menu manually once.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →