Launching Edge Browser for Testing using Selenium

Over my past decade in test automation across various browsers, I have observed the Microsoft Edge browser to be one of the most underestimated when it comes to cross-browser testing.

While most teams only focus on testing with Chrome, Firefox and Safari which dominate over 70% of the browser market share, the ignorance towards Edge browser can cause issues reaching a segment of your users.

In this guide aimed at test automation engineers and SDETs, let‘s go through a detailed guide on setting up Microsoft‘s Edge browser for automated testing using Selenium.

Understanding the Relevance of Edge Browser

Now you may ask – with under 5% market share globally, why should we care about testing on Edge?

As per StatCounter‘s data below, Edge browser (including legacy EdgeHTML versions) still constitutes close to 8% of desktop browser market share in the US.

In the enterprise market and Windows-based corporate environments, this share is often much higher from my experience – with some internal apps built primarily for IE/Edge compatibility.

Besides market share, Microsoft‘s brand visibility and bundling of Edge across all Windows 10 machines translates into a sizeable user base that could be impacted if your web application does not work on Edge.

While the new Chromium-powered Microsoft Edge aims to provide greater web standards alignment, the legacy EdgeHTML versions still power 100s of millions of PCs worldwide.

Hence it becomes critical to test web apps across both legacy and modern Edge browsers with sufficient test coverage through automation. Else you risk unexpected client escalations later down the line.

Key Versions of Microsoft Edge Browser

As highlighted earlier, there are two main variants of Edge browser in circulation today:

Legacy EdgeHTML-based

Launched in 2015 across Windows 10, this included EdgeHTML engine powerful proprietary features like Smooth Scrolling. Key versions:

  • Edge v20-18: Released from 2015 to 2019
  • Incompatible with modern web standards
  • Reached End of Support in Jan 2021

Chromium-powered Edge

In 2020, Microsoft rebuilt Edge using the open-source Chromium engine for better compatibility.

  • Evergreen Chromium engine gets frequent feature updates
  • Runs on all platforms like Windows, MacOS, Linux etc.
  • Additional enterprise-focused features

The key is to test web applications across both variants to address entire Edge user base.

Step-by-Step Guide to Configuring EdgeDriver in Selenium

Now that we have understood the background, let me walk you through the key steps to set up EdgeDriver for test automation using Selenium:

Pre-requisites

Before configuration, ensure that:

✔️ You are using Windows 10/11 machine (for EdgeLegacy browser access)
✔️ Selenium Java binding JAR files are setup in your project
✔️ Relevant Edge browser version is installed

1. Identify Windows OS Version

This is critical to download the right EdgeDriver executable file.

To find OS version:

Start > Settings > System > About

Take note of OS Build number, Windows version etc.

For example:

Windows 10 Pro Version 21H1 (OS Build: 19043.1706)

2. Download Exact EdgeDriver Version

Now visit Microsoft‘s EdgeDriver download page:

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

Identify the driver version matching your Windows OS build.

For our example, we need:

Driver version: 103.0.1264.62
Supports OS build: 19043+

Make sure to pick the right architecure based on your machine: x64 or x86.

3. Set System Property for EdgeDriver Path

Unzip the EdgeDriver exe file to your project location.

In your Java test script, use System.setProperty to configure executable path:

System.setProperty("webdriver.edge.driver","C:/EdgeDriver/msedgedriver.exe");  

4. Instantiate New EdgeDriver Instance

Now create a new EdgeDriver object to kickstart test automation:


WebDriver driver = new EdgeDriver();

Follow this with your test steps using Selenium API.

Demo Test Automation Script Using EdgeDriver

Let‘s look at a simple Selenium Java test script to validate EdgeDriver configuration:


//Import Selenium packages
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class EdgeTest {

  public static void main(String[] args) {

    //Set EdgeDriver path
    System.setProperty("webdriver.edge.driver","C:/EdgeDriver/msedgedriver.exe");

    //Create EdgeDriver instance
    WebDriver driver = new EdgeDriver();

    //Open example website
    driver.get("https://example.com");

    //Validate page title 
    String pageTitle = driver.getTitle();

    if(pageTitle.equals("Example Domain")) {
      System.out.println("Test Passed");
    } else {
      System.out.println("Test Failed");
    }

    //Close browser
    driver.quit();

  }

}

This script opens example.com website using Edge browser and asserts the page title to validate that Edge browser launched successfully.

You can integrate data-driven testing to parameterize test data, add assertions for elements on the page and build out complex end-to-end test scenarios.

Additional Tips for Edge Browser Test Automation

Now that you know how to configure EdgeDriver, here are some additional best practices:

✔️ Run tests against both legacy and new Chromium Edge versions
✔️ Retry failed tests up to 3 times before flagging
✔️ Ensure Edge browser auto-updates are disabled
✔️ Leverage Docker for test parallelization

How Mac Users Can Test on Edge

As Microsoft Edge only runs on Windows platform, how can MacOS/Linux users test their web apps on Edge browser?

An optimal cross-browser testing strategy is to utilize cloud testing platforms like BrowserStack.

BrowserStack provides instant access to thousands of Windows devices with Edge browser versions installed on their cloud infrastructure through their website and automation SDKs.

This enables easy collaboration between teams with different development/test environments while validating on the same set of browsers.

Advanced features like network traffic shaping, console logs, visual testing and automatic screenshots make debugging of test failures easier.

I highly recommend considering cloud-based solutions instead of complex VM/emulator setups for reliable cross-platform browser testing.

Next Steps

I hope this detailed guide gives you clarity on configuring Microsoft‘s Edge browser for test automation using Selenium bindings.

Here are some additional resources to level up your skills:

👉 BrowserStack Selenium Java Tutorial: https://www.browserstack.com/guide/selenium-java-tutorial

👉 TestNG Framework Introduction: https://testng.org/doc/documentation-main.html

👉 Sauce Labs Real Device Cloud: https://saucelabs.com/platform

Feel free to reach out if you have any other questions around test automation strategies for Edge or other browsers. I‘m happy to help!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.