Table of Contents
Enroll in Selenium Training

Microsoft Edge may be one of the newest entrants in the browser arena but has already garnered traction among the users. Moreover, it has been built from scratch, keeping in mind the performance, privacy, and security as one of the important criteria. With around 7% of market share and backing from Microsoft, Edge has gathered a great brand reputation. So, this has become quite crucial for the testing teams to test their web applications on the Edge browser. Additionally, testing on multiple browsers ensures compatibility and makes sure that the application performs flawlessly on different browser platforms. Like other browser vendors, Microsoft Edge also provides a driver named "EdgeDriver", which acts as an intermediatory between Selenium and the Edge browser and helps in executing the Selenium test cases on the Edge browser.

Subsequently, in this article, we will cover the details of how we can Run Selenium test on Edge browser using EdgeDriver by covering the details on the following topics:

  • What is Selenium EdgeDriver?
  • What are the pre-requisites for Selenium EdgeDriver?
  • How to install EdgeDriver on Windows?
  • How to download EdgeDriver on Windows?
  • And how to setup EdgeDriver on Windows?
  • And how to run Selenium tests on Edge Browser on Windows?
  • How to install EdgeDriver on macOS?
  • How to download EdgeDriver in macOS?
  • And how to setup EdgeDriver on macOS?
  • And how to run Selenium tests on Edge Browser on Mac?

What is Selenium EdgeDriver?

Microsoft offers Microsoft WebDriver to execute the Selenium WebDriver automation tests on the Edge browser. Additionally, the driver allows the selenium tests to communicate with the Edge browser for executing Selenium tests. Moreover, the Edge driver comes with different versions depending upon your browser version or whether your system is x86 or x64. Any version can be downloaded based on the browser version that you want to use.

Selenium Edge

Further, Microsoft, in January 2020, announced an all-new version of the Edge browser. The new version has been build on top of the Chromium engine, similar to Google Chrome. Moreover, the previous version of the Microsoft Edge browser was based on the EdgeHTML engine. Subsequently, to understand the difference between these two browser engines, you can refer to the link "Difference between browser enginers. " To distinguish between both versions of the Edge browser, Microsoft calls the Chromium version simply as "Edge" and the older version as "Edge Legacy".

So, while downloading, make sure that you download the correct driver for Edge or Edge Legacy based on your current browser version.

What are the pre-requisites for Selenium EdgeDriver?

Before we can jump on writing our Selenium tests for the Edge browser, lets first look at a few of the prerequisites that are required for executing our Selenium tests. Subsequently, we will look at all the configurations and programs that we are needed for running the Selenium test cases on the Edge browser:

  1. Edge Browser: The most obvious prerequisite, make sure that you have installed the Edge browser on your system. In addition to this, we would recommend the newest version, but the existing version will work as good as long as you can get the right driver for the specified version.
  2. Java JDK: JDK or Java Development Kit is required for writing java programs. As we will be writing our Selenium tests in java, having JDK is a must. Moreover, to know how to download and install Java JDK, read the complete tutorial here: How to install Java?
  3. Eclipse IDE: Eclipse is one of the most popular Java IDE in the market. Additionally, you can download one easily from its official site and set it up for java programming. Moreover, to learn about Eclipse and its setup, read our previous tutorial on the same: Download and Install Eclipse.
  4. Selenium: Latest version of the Selenium WebDriver will be required for setup. However, you can use any of the latest stable version. In this tutorial, we will be using the latest Selenium 4. Additionally, you can learn to set up Selenium with Eclipse here: Configure Selenium WebDriver.

How to install EdgeDriver on Windows?

Once we are done with all the prerequisites downloads and setups, we are ready to move ahead. The next step will be to install the EdgeDriver on the Windows platform. Consequently, let's start with downloading the EdgeDriver compatible with the Edge browser on your machine.

How to download EdgeDriver on Windows?

Before we start to download the EdgeDriver, we will first need to check the version of the Edge browser in our system. As the EdgeDriver version depends upon the browser version, it becomes a necessity to download the compatible version of the driver. You can check the version of the Edge browser by following the steps as mentioned below:

  1. First, open the Edge browser and click on the "Settings and More" (the three dots) at the right top corner or press alt + F.

  2. Secondly, hover over "Help and Feedback " in the settings menu.

  3. Thirdly, click on About Microsoft Edge.

Settings and more of Edge Browser

  1. Consequently, this will open up the page with all the details about your Edge browser.

About Edge get the version of Edge browser

Now, as we have the version of the Microsoft Edge browser, we can go ahead and download the EdgeDriver form the official Microsoft Edge WebDriver site. Follow the steps as mentioned below to download the EdgeDriver:

  1. First, navigate to the download page of the Microsoft Edge WebDriver.

  2. Second, scroll down a little to the download section and select the compatible version as shown below:

Download EdgeDriver compatible version

  1. Thirdly, make sure to download the correct version. In the above image, we have shown x86 and x64 are the compatible versions for the Windows platform; you can download any version that is compatible with your browser and operating system. For example, as our browser version is 84 (64-bit), we will be downloading the x64 version for the Release 84.

  2. After that, once the download is complete, extract the zip file and place the content at any preferred location.

  3. Now, open eclipse and create a Java project. Add all the dependencies to the project. Additionally, to learn how to set up a Java project along with Selenium WebDriver in Eclipse, visit our detailed tutorial at Configure Selenium WebDriver.

Now that we have downloaded the EdgeDriver let's see how we can configure the same, so as the same can be used in the Selenium test scripts.

How to setup EdgeDriver on Windows?

To set up and configure EdgeDriver with the Selenium, the EdgeDriver executable file should be accessible in the test script. Selenium tests can access the EdgeDriver if it is set up by any of the following ways:

  1. Setup EdgeDriver using System Properties in Environment Variables.
  2. Setup EdgeDriver using System Properties in the test script.

Let’s comprehend all of these and try running our test code with Selenium 3 or Selenium 4.

How to setup EdgeDriver using System Properties in Environment Variables?

On Windows, one of the ways to declare system-level variables is by using Environment Variables. Users can define either user-level environment variables or system-level variables. Environment variables can be used to set the path for the EdgeDriver directly into the system properties. So, whenever a needed instance of WebDriver can easily locate the path of EdgeDriver from the system variable. Let's follow the below steps to set up the system property path for EdgeDriver.

  1. First, we need to open the Environment Variable pop-up. To do that, click on the search bar and search for “Environment Variables“. It will search and display “Edit environment variables for your account”, as shown in the image below. Click on the “Open” to open the System Properties pop-up.

How to access Environment Variables on Windows 10

  1. The “System Properties” pop-up will open. In the pop-up, select the “Advanced ” tab as marked by the arrow. After that, under the Advanced tab, click on the “Environment Variables” button.

Environment Variable on Windows

  1. This will open the “Environment Variables” pop-up. In the pop-up System variables section, look for the “Path” variable as marked in the below image. Click on the Path variable to select it. Once selected, click on the “Edit ” button as marked by the arrow.

System Variable on Windows

  1. Fourthly, in the “Edit environment variable” pop-up, click on the “New ” button.

Edit Environment Variables on Windows

  1. Clicking the "Edit " button will add a new line. Now, add the EdgeDriver’s executable file's parent folder location to the path. We have placed our driver at the following location “C:\Selenium\edgedriver”, so we have added the same as the path variable. Once done, click on the “OK ” button as denoted by the arrow.

EdgeDriver to Systems variables Path

How to Run Selenium Tests on Edge Browser using EdgeDriver on Windows?

We can now directly initialize the WebDriver instance using the EdgeDriver, as shown below:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class DemoEdge {
    public static void main(String[] args) throws InterruptedException{

        System.out.println("Execution after setting EdgeDriver path in System Variables on Windows!!");
        WebDriver driver = new EdgeDriver();
        driver.get("https://demoqa.com");
        Thread.sleep(3000);
        driver.quit();
        System.out.println("Execution complete on Windows");

    }
}

On executing the above code, you will see the results like below:

Run Selenium tests on Edge browser

It is clear from the console results, there is no WebDriver error, which implies that the WebDriver set up is correct. You can see the print statements as the entry and exit points of our execution. Correspondingly you will be able to see the execution in your system.

How to initialize EdgeDriver using System Properties in the Selenium test script?

Now, instead of using the global instance of EdgeDriver, if we want to use a specific version of EdgeDriver, we can do the same by explicitly specifying the path of the EdgeDriver in the test script itself. We just need to add a single line of code to set up the system properties for the EdgeDriver, as shown below:

System.setProperty("webdriver.edge.driver", "<Path of the EdgeDriver Executable>")
;

Let us modify the code we used above and see that we can launch the Edge browser successfully. The modified code would look like this:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class DemoEdge {
    public static void main(String[] args) throws InterruptedException{

        System.out.println("EdgeDriver execution on Windows!!");
        System.setProperty("webdriver.edge.driver", "E:\\EdgeDriver\\85\\msedgedriver.exe");
        WebDriver driver = new EdgeDriver();
        driver.get("https://demoqa.com");
        Thread.sleep(3000);
        driver.quit();
        System.out.println("Execution complete on Windows");

    }
}

You will see that demoqa.com  opens in the Edge browser without any error and exception.

selenium test on edge browser

So, this way, you can run your Selenium test cases on a specified version of EdgeDriver, by giving the explicit path of the EdgeDriver in the setProperty() method.

How to install EdgeDriver on macOS?

The installation and setup of EdgeDriver on macOS is almost the same as that of the Windows platform, the only difference being the executable for macOS will be different. Additionally, the way we can include the EdgeDriver executable in the System’s PATH variable is bit different. Subsequently, let’s see how we can install and setup the EdgeDriver on macOS :

How To Download EdgeDriver in macOS?

On macOS, we can download EdgeDriver from the official Mircosoft Edge website. Consequently, depending on the version of the "Edge browser", click on the corresponding EdgeDriver for mac, as highlighted below:

EdgeDriver for macOS

As we do have the Edge browser version 85 on our machine, so we are downloading the corresponding compatible version of the EdgeDriver.

It will download a zip file, which you can extract in any of the folders of your choice. After extracting, it will show the executable file of EdgeBrowser, as shown below:

EdgeDriver executable for macOS

So, now you have the EdgeDriver executable file available on your machine, which we can use in our test scripts. Subsequently, let’s see how to setup EdgeDriver on macOS and use in the Selenium test scripts:

How To Set Up EdgeDriver on macOS?

Now that you have downloaded the EdgeDriver, the next step is to set it up so that you can use it in your test scripts. On macOS  also, we can follow the same ways, as on Windows, to set up the EdgeDriver:

  1. Setup EdgeDriver using the System’s PATH variable.
  2. Setup EdgeDriver using System Properties in the test script.

The 2nd point is the same setup as the Windows platform, as we are using JAVA for test development, and JAVA being platform-independent, will have the same behavior across platforms. So, let’s see how we can set up the EdgeDriver using the System’s PATH variable:

How to Setup EdgeDriver using the System’s PATH variable?

As we mentioned above, one of the easiest ways to make the executable available globally on the macOS is to copy the executable under any the folders which are already in the PATH variable. Let’s follow the steps mentioned below to achieve the same:

  1. First, identify the folders which are included in the PATH variable using the command ‘echo $PATH ‘ on the terminal. It will give a sample output, as shown below:

Validate folders in macOS PATh variable

  1. Secondly, as we can see, multiple directories are already part of the PATH variable. Suppose we choose “/usr/local/bin ” as a placeholder directory to hold the EdgeDriver executable.

  2. Thirdly, copy the EdgeDriver executable file from the downloaded directory to the “/usr/local/bin ” directory using the mv command as shown below:

mv msedgedriver /usr/local/bin/ 

or 

cp msedgedriver /usr/local/bin/

How to Run Selenium Tests on Edge Browser using EdgeDriver on Mac?

Now your EdgeDriver is ready to be used in your Selenium test scripts. Consequently, now we will write a simple program and execute the same in the macOS platform.

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;

public class DemoEdge {
    public static void main(String[] args) throws InterruptedException{

        System.out.println("EdgeDriver execution on macOS!!");
        WebDriver driver = new EdgeDriver();
        driver.get("https://demoqa.com");
        Thread.sleep(3000);
        driver.quit();
        System.out.println("Execution complete on macOS");

    }
}

On executing the same, you can find the results in your console window:

selenium test on edge EdgeDriver execution on macOS

You can see the execution happening successfully without any error. Both the print statements are getting displayed, which indicates that our execution did not face any error. So did you see how easy it was to run EdgeDriver tests in macOS? Unlike the Windows system, where you have to remember the path of your driver executable, just placing the driver at a location in macOS makes our lives so easy!

Key Takeaways

  • Microsoft has rebuilt the Edge from scratch on the Chromium engine. Additionally, with around 7 percent of market share, Edge still makes a decent argument to test your applications on Edge for compatibility.
  • Moreover, Selenium's cross-browser functionality allows users to perform tests on all different types of contemporary browsers, including but not limited to Microsoft Edge.
  • In addition to the above, MSEdgeDriver is a standalone server that communicates between Selenium WebDriver and Microsoft Edge to execute all selenium tests on the Edge browser.
Run Selenium Tests on Internet Explorer
Run Selenium Tests on Internet Explorer
Previous Article
Internet Explorer Driver Server
Internet Explorer Driver Server
Next Article

Similar Articles

Feedback