Use WebDriver to automate Microsoft Edge - Microsoft Edge development (2023)

  • Article
  • 10 minutes to read

WebDriver lets you automate Microsoft Edge by simulating user interactions. Tests using WebDriver have a few advantages over JavaScript unit tests running in the browser:

  • WebDriver accesses functions and information that are not available to JavaScript running in browsers.

  • WebDriver simulates user events or operating system level events more accurately than JavaScript unit tests.

  • WebDriver manages multiple windows, tabs, and web pages in a single testing session.

  • WebDriver runs multiple sessions of Microsoft Edge on a given computer.

Relationship between WebDriver and other software

To automate Microsoft Edge with WebDriver to simulate user interactions, you need three components:

  • Microsoft Edge.
  • Microsoft Edge WebDriver.
  • A WebDriver testing framework.

The functional relationship between these components is as follows:

TechnologyRolle
WebDriverA W3C standard for a platform and language neutral wire protocol. This protocol allows out-of-process programs to remotely control the behavior of web browsers.
Microsoft Edge WebDriverMicrosoft's implementation of the WebDriver protocol specifically for Microsoft Edge. Test authors write tests that use WebDriver commands that Microsoft Edge WebDriver receives. Edge WebDriver is then responsible for transmitting this command to the browser.
A WebDriver testing frameworkTest authors use a test framework to write end-to-end tests and automate browsers. Provides a language-specific interface that translates your code into commands sent to Edge WebDriver. WebDriver test frameworks exist for all major platforms and languages. One such framework is Selenium.
Internet Explorer driverAn open source implementation of the WebDriver protocol specific to Internet Explorer. To run legacy end-to-end tests for Internet Explorer mode, we recommend using the Internet Explorer driver.
Microsoft WebDriver (Legacy)The previous browser-specific driver for Microsoft Edge (EdgeHTML), also known as Microsoft Edge Legacy.

The following sections describe how to get started with WebDriver for Microsoft Edge.

Download Microsoft Edge Web Driver

To start writing automated tests, make sure that the Edge WebDriver version you have installed matches your browser version, as follows:

  1. Go toedge://settings/helpand note your version of Microsoft Edge.

    (Video) #16 Launching MS Edge Browser Using Selenium WebDriver | Selenium Tutorial for Beginners

    Use WebDriver to automate Microsoft Edge - Microsoft Edge development (1)

  2. Go toMicrosoft Edge WebDriver.

  3. ImGet the latest versionIn the section of the page, select a platform in the channel that matches your Microsoft Edge version number.

    Use WebDriver to automate Microsoft Edge - Microsoft Edge development (2)

  4. After the download is complete, extract themsedgedriverexecutable at your preferred location. Add the folder where the executable is locatedAWAYenvironment variable.

Select a WebDriver test framework

After downloading Edge WebDriver, the last component you need to download is a WebDriver test framework. Test authors use WebDriver test frameworks to write end-to-end tests and automate browsers. A WebDriver testing framework provides a language-specific interface that translates your code into commands that Edge WebDriver runs in Microsoft Edge. WebDriver test frameworks exist for all major platforms and languages ​​such as Python, Java, C#, Ruby and JavaScript.

This article provides instructions for using the Selenium framework, but you can use any library, framework, or programming language that supports WebDriver. To perform the same tasks with a WebDriver testing framework other than Selenium, consult the official documentation for the framework of your choice.

use of selenium 4

Selenium WebDriver is an open-source testing framework that can be used on any platform and provides language bindings for Java, Python, C#, Ruby, and JavaScript. Note: Python 3 is required to run Selenium 4 tests. (Python 2.7 is not supported.)

To use WebDriver to automate Microsoft Edge, if using Selenium, you must use Selenium 4, which has built-in support for Microsoft Edge (Chromium).

To install Selenium 4, seeInstall a Selenium library. In case you need it, the Nuget packages page is thereSelenium.WebDriver.

Upgrading from Selenium 3

To use WebDriver to automate Microsoft Edge, if using Selenium, make sure you are using Selenium 4. Selenium 3 is no longer supported.

You need to upgrade existing Selenium 3 tests to Selenium 4. For more information on upgrading to Selenium 4, seeUpdate to Selenium 4.

(Video) #4 How to Configure Microsoft Edge Driver for Selenium

If you useSelenium Tools for Microsoft EdgeTo add Microsoft Edge (Chromium) support to your Selenium 3 browser tests, update your tests as follows:

  1. Remove Selenium Tools for Microsoft Edge from your project. You do not need to use Selenium Tools for Microsoft Edge with Selenium 4 as Selenium 4 already has built-in support for Microsoft Edge (Chromium).

  2. Update your tests to use the built-in onesEdgeDriverand related classes that Selenium 4 provides instead.

  3. Remove all uses ofEdgeOptions.UseChromiumProperty. This property is no longer present in Selenium 4, as Selenium 4 only supports Microsoft Edge (Chromium).

Automate Microsoft Edge with WebDriver

To automate a browser with WebDriver, you must first start a WebDriver session with a WebDriver test framework. A web drivermeetingis a single running instance of a browser controlled via WebDriver commands.

Start a WebDriver session to launch a new browser instance. The launched browser instance remains open until you close the WebDriver session.

The following section will guide you through using Selenium 4 to start a WebDriver session with Microsoft Edge.

note

This article provides instructions for using the Selenium framework, but you can use any library, framework, or programming language that supports WebDriver. To perform the same tasks with a different framework, consult the documentation for the framework of your choice.

Automate Microsoft Edge

Selenium uses theEdgeDriverClass for managing a Microsoft Edge session. The following code:

  1. Starts a Microsoft Edge session.
  2. Tells Microsoft Edge to switch to Bing.
  3. Search for "WebDriver".
  4. Sleeps for a few seconds so you can see the results.

To start automating Microsoft Edge with WebDriver, copy and paste the code snippet for your preferred language:

(Video) Python Selenium Tutorial - Microsoft Edge Setup

  • C#
  • Python
  • Java
  • JavaScript
Using OpenQA.Selenium;Using OpenQA.Selenium.Edge;Using System.Threading;Namespace EdgeDriverSample{ class Program { static void Main(string[] args) { var driver = new EdgeDriver(); try { driver.Url = "https://bing.com"; var element = driver.FindElement(By.Id("sb_form_q")); element.SendKeys("WebDriver"); element.Submit(); Thread.Sleep(5000); } finally { driver. End (); } } }}

Manage and configure the Edge WebDriver service

When you create a new oneEdgeDriverObject to start a Microsoft Edge session, Selenium starts a new Edge WebDriver process that uses theEdgeDriverObject communicates with. The Edge WebDriver process closes when you invoke theEdgeDriverObjectStopMethod. let everyoneEdgeDriverObject management of your own driver process can be inefficient for many tests because each test has to wait for a new driver process to start. Instead, you can create a single Edge WebDriver process and then reuse it for multiple tests.

Selenium uses theEdgeDriverServiceclass for managing an Edge WebDriver process. You can create oneEdgeDriverServiceonce before you run your tests and then pass themEdgeDriverServiceopposition to theEdgeDriverconstructor when creating a new oneEdgeDriverObject. If you happen toEdgeDriverServiceto theEdgeDriverconstructor, theEdgeDriverobject will use thisEdgeDriverService, instead of creating a new one.

You can also useEdgeDriverServiceto configure command line options for the Edge WebDriver process as shown below.

The following snippet creates a new oneEdgeDriverServiceand enables verbose log output:

  • C#
  • Python
  • Java
  • JavaScript
var service = EdgeDriverService.CreateDefaultService();service.UseVerboseLogging = true;var driver = new EdgeDriver(service);

Configure Microsoft Edge options

You can pass oneEdgeOptionsopposition to theEdgeDriver-Constructor to configure additional options for the Microsoft Edge browser process. The following section shows how to use itEdgeOptionsfor some common scenarios. For a full list of supported options seeAbilities and Edge Options.

Choose specific browser binaries

You can start a WebDriver session with specific Microsoft Edge binaries. For example, you can run tests with theMicrosoft Edge preview channels, wie Microsoft Edge Beta, Dev oder Canary.

  • C#
  • Python
  • Java
  • JavaScript
var options = new EdgeOptions();options.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe";var driver = new EdgeDriver(options);

Pass additional command line arguments

You can useEdgeOptionsto configure command line arguments passed to the Microsoft Edge browser process when creating a session. For example, you can configure the browser to run in headless mode.

  • C#
  • Python
  • Java
  • JavaScript
var options = new EdgeOptions();options.AddArgument("headless");var driver = new EdgeDriver(options);

Change the WebDriver Installation option

Docker

if you useDocker, run the following command to download a preconfigured image that has Microsoft Edge and Microsoft Edge WebDriver preinstalled.

(Video) 🔥 How to Launch MS Edge Browser in Selenium | EdgeOptions & Capabilities | - Selenium Session 14🔥

docker run -d -p 9515:9515 mcr.microsoft.com/msedge/msedgedriver

For more information, seemsedgedriver container on Docker Hub.

application protection

Trusted websites using Microsoft Defender Application Guard can be automated with Edge WebDriver. Microsoft Defender Application Guard is also calledapplication protection, kurz.

Untrusted websites using Application Guard cannot be automated or manipulated with Edge WebDriver. Application Guard launches untrusted websites in a container, and this container doesn't expose the remote debugging port that Edge WebDriver needs to communicate with the website.

Your company administrator defines what are trusted sites, including cloud resources and internal networks. Websites that are not included in the list of trusted websites are taken into accountuntrustworthy. Edge WebDriver can automate both InPrivate windows and sites in the Trusted Sites list.

For more information on Application Guard, see:

  • Microsoft Edge support for Microsoft Defender Application Guard.
  • Microsoft Defender Application Guard overview.

Disable diagnostic data collection

By default, Edge WebDriver sends diagnostic data such as the status of theNew sessionWebDriver command to Microsoft. To disable the collection of diagnostic data for Edge WebDriver, set theMSEDGEDRIVER_TELEMETRY_OPTOUTenvironment variable too1. For more information about the data collected by Edge WebDriver, seeMicrosoft Edge Privacy White Paper.

Legacy Microsoft WebDriver for EdgeHTML

Microsoft WebDriver is the legacy WebDriver implementation for EdgeHTML-based Microsoft Edge. Microsoft WebDriver was distributed as an optional Windows component as the legacy Microsoft Edge (EdgeHTML) was updated with the operating system. Microsoft WebDriver is not compatible with the latest Chromium-based versions of Microsoft Edge. Microsoft WebDriver is still made available for developers who have written WebDriver-based tests for UWP apps since they are based on EdgeHTML, but Microsoft WebDriver is no longer recommended.

SeeWebDriver (EdgeHTML).

Troubleshooting

These are troubleshooting considerations when using WebDriver to automate Microsoft Edge.

Developer Tools Availability Policy

If your IT admin has theDeveloperToolsAvailabilitypolitics too2, Microsoft Edge WebDriver is prevented from controlling Microsoft Edge because the driver is usingMicrosoft Edge-DevTools. To automate Microsoft Edge, make sure that theDeveloperToolsAvailabilitypolicy is set0or1.

Upgrade from Selenium 3 to Selenium 4

To use WebDriver to automate Microsoft Edge, if using Selenium, make sure you are using Selenium 4. Selenium 3 is no longer supported.

If you are using Selenium 4, you do not need to use Selenium Tools for Microsoft Edge. Selenium Tools for Microsoft Edge is for Selenium 3 only. If you are trying to use Selenium 4 with Selenium Tools for Microsoft Edge and trying to install a newEdgeDriverexample, you receive the following error message:System.MissingMethodException: "Method not found: "OpenQA.Selenium.Remote.DesiredCapabilities OpenQA.Selenium.DriverOptions.GenerateDesiredCapabilities(Boolean)".

(Video) Selenium 4: How To Run Tests using Microsoft Edge Chromium Browser

If you are using Selenium 4 and getting this error, removeMicrosoft.Edge.SeleniumToolsfrom your project and make sure you use the official oneEdgeOptionsandEdgeDriverclasses from theOpenQA.Selenium.Edgenamespace.

See also

  • Das Selenium Browser Automation Project- Information about WebDriver in the context of Selenium and how to write automated WebDriver tests with Selenium.
  • Contact the Microsoft Edge WebDriver teamto send feedback on using WebDriver, WebDriver testing frameworks (like Selenium) and Microsoft Edge.

FAQs

How to automate edge browser using Selenium Python? ›

Automated Browser Testing with Edge and Selenium in Python
  1. Download Selenium Edge WebDriver.
  2. Performing Browser Automation With Edge And Selenium In Python.
  3. Running Your First Automated Browser Testing Script.
  4. Performing Browser Automation Using Web Locators.

How to open ms Edge with specific profile with Selenium WebDriver? ›

You could use user-data-dir and profile-directory to use specific profile to launch Edge with Selenium. The sample code is like below: System. setProperty("webdriver.

How do I automate Edge without selenium? ›

Linked
  1. Automating Edge IE Mode using VBA (without third-party software)
  2. VBA Script to convert from internet explorer to Edge or chrome browser.
  3. Automate data-entry on Edge using Excel macro.
  4. Open Edge in IE Mode using VBA.
  5. -1. ...
  6. VBA automate Edge Browser without downloading any external things.
Jan 7, 2022

What is Microsoft Edge WebDriver? ›

To create automated tests that simulate user interactions for your WebView2 app, you can use Microsoft Edge WebDriver. Microsoft Edge WebDriver is Microsoft's implementation of the W3C WebDriver protocol. The W3C WebDriver protocol allows programs to control the behavior of web browsers.

How to automate Edge browser using VBA? ›

You need to:
  1. Define InternetExplorerOptions with additional properties that point to the Microsoft Edge browser.
  2. Start an instance of InternetExplorerDriver and pass it InternetExplorerOptions . IEDriver launches Microsoft Edge and then loads your web content in IE mode.
Apr 27, 2022

Does Selenium IDE work with Edge? ›

It's available for Google Chrome, Mozilla Firefox, and Microsoft Edge.

Which browsers can Selenium automate? ›

If you want to create quick bug reproduction scripts, create scripts to aid in automation-aided exploratory testing, then you want to use Selenium IDE; a Chrome, Firefox and Edge add-on that will do simple record-and-playback of interactions with the browser.

Which driver is used for Edge browser? ›

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.

How do I run a script in Microsoft Edge? ›

Press Ctrl + Shift + P (Windows, Linux) or Command + Shift + P (macOS) to open the Command Menu. Press Enter to run the Snippet.

What are the three 3 different ways to open Microsoft Edge? ›

Windows 10 has shortcuts for Microsoft Edge on the desktop, the taskbar, and the Start Menu, by default. For example, you can open Microsoft Edge by double-clicking or double-tapping on its desktop shortcut. You can also click or tap on the Edge shortcut from your taskbar.

How to execute Selenium scripts on already opened Edge browser? ›

We can connect to an already open browser using Selenium webdriver. This can be done using the Capabilities and ChromeOptions classes. The Capabilities class obtains the browser capabilities with the help of the getCapabilities method.

What Cannot be automated using selenium? ›

Selenium is a tool that can't be used to automate desktop applications testing as it can't recognize the objects in desktop apps. It's only targeted at conducting tests of web apps, using various browsers listed above.

Can VBA work with Edge? ›

VBA initially only supported Internet Explorer-based automation, but once Microsoft discontinued Internet Explorer, they deployed some updates so that VBA's InternetExplorer module can run the Microsoft Edge browser in IEMode without any issues.

What is Edge automation? ›

Simplify edge infrastructure management by automating hardware and virtual infrastructure. Edge cloud infrastructure consists of thousands of edge sites.

What is the difference between WebDriver and ChromeDriver? ›

A ChromeDriver is a separate executable or a standalone server that Selenium WebDriver uses to launch Google Chrome. Here, a WebDriver refers to a collection of APIs used to automate the testing of web applications.

Is WebDriver the same as Selenium? ›

Introducing Selenium IDE vs WebDriver

Selenium WebDriver is a code library of APIs for controlling browsers. In comparison, Selenium IDE is a browser plug-in designed for recording and playing back tests.

What is WebDriver and how it works? ›

WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.

Is VBA good for automation? ›

VBA is a powerful tool that can automate processes and save your business time and money. By eliminating the potential for human error, you can also improve the accuracy of your data. VBA is highly flexible and can be used by all departments in your company to streamline their work.

Can VBScript run on Microsoft Edge? ›

VBScript functionality is available in Microsoft's Edge browser for users who need to run a legacy web application that contains VBScript code. This is done using IE mode and changing the version of IE to IE10 in the operating system's group policy function.

Do Java applets work in Edge? ›

The Edge browser does not support plug-ins and therefore will not run Java.

How to download Microsoft Edge WebDriver for selenium? ›

Open Microsoft Edge Webdriver page using this link – https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Click on Downloads and from the list of different versions of Edge drivers, download the latest one or as per your requirement. This will download the msi file.

What programming language does Edge use? ›

EdgeHTML is written in C++. The rendering engine was first released as an experimental option in Internet Explorer 11 as part of the Windows 10 Preview 9926 build.

Does Microsoft Edge have developer tools? ›

The Microsoft Edge browser comes with built-in web development tools, called Microsoft Edge DevTools. DevTools is a set of web development tools that appears next to a rendered webpage in the browser. DevTools provides a powerful way to inspect and debug webpages and web apps.

Which browser is not supported by Selenium WebDriver? ›

Where possible, WebDriver drives the browser using the browser's built-in support for automation. Since all the driver implementations except for Internet Explorer are provided by the browser vendors themselves, they are not included in the standard Selenium distribution.

Which is the best site to automate using Selenium? ›

List of Websites to Practice Selenium
  1. https://phptravels.com/demo/ ...
  2. http://thedemosite.co.uk/ ...
  3. http://newtours.demoaut.com/ ...
  4. http://the-internet.herokuapp.com/ ...
  5. http://automationpractice.com/index.php. ...
  6. http://book.theautomatedtester.co.uk/ ...
  7. https://s1.demo.opensourcecms.com/wordpress/

How do I set my browser to auto? ›

Select the Start button, and then type Default apps. In the search results, select Default apps. Under Web browser, select the browser currently listed, and then select Microsoft Edge or another browser.

How do you Autoscroll on Edge? ›

Using Auto Scroll
  1. Select. > Ride Settings.
  2. Select Auto Features > Auto Scroll.
  3. Select a display speed.

How do I enable autoplay in Edge? ›

Click on Cookies and site permissions. You can also type in edge://settings/content/mediaAutoplay in a new tab. Click on the dropdown menu next to Control if audio and video play automatically on sites. Choose from Allow or Limit.

What is the automation browser? ›

Browser Automation is the act of testing software in a web browser using automated solutions, to reduce the overall testing efforts and aims to deliver faster results efficiently. It helps in building better quality software with fewer efforts involved.

How do I automate browser actions in Chrome? ›

How to Automate Chrome
  1. Download and install a free trial of Automate.
  2. Click on New Recording from the Automate Task Builder to launch the Automate Recorder.
  3. From the Automate Recorder, click the Web icon.
Nov 12, 2019

How does browser autofill work? ›

After you interact with the first field in the address form, the browser shows you a list of saved addresses. You can choose one, and the browser fills in all fields related to the address. Autofill makes filling out forms fast and easy. Not every address form has the same fields, and the order of fields also varies.

How do I use AutoScroll extension? ›

With Simple Autoscroll, you simply set how many pixels to scroll at set intervals, press "Go", and start reading! To stop the scrolling, simply click on the extension icon and the scrolling will cease. Simple as that! Tips: For a smooth scrolling experience, simple input lower values for both pixels and milliseconds.

What is edge development platform? ›

An edge computing platform drives edge computing by: Enabling real-time data processing away from the central cloud or data center. Caching, buffering, and optimizing the data close to the edge device or IoT system. Transforming the data received by edge devices and IoT into a format that can be processed for analysis.

What is edge Mlops? ›

Abstract: Artificial Intelligence of Things (AIoT) is the combination of artificial intelligence (AI) technologies with the Internet of Things (IoT) infrastructure to achieve more efficient IoT operations and decision making.

What is edge AI application? ›

Edge AI software is large number of machine learning algorithms that run on a physical hardware device. The idea is to run AI algorithms on a local device or machine. Edge AI software allows users to get data in real-time because it does not need other systems or internet connections to connect to others.

Videos

1. How to Scale Your Cross Browser Testing | How to Perform Cross Browser Testing in Testsigma
(Krishna Sakinala)
2. How to launch Microsoft Edge browser in Selenium WebDriver python
(KB Tutorials)
3. Install & Setup Selenium Python For Edge Browser (For Beginners)
(Jie Jenn)
4. Run WebdriverIO Tests on Microsoft Edge | Launch Microsoft Edge Browser Using WebdriverIO
(Julia Pottinger)
5. How to download files on MS Edge using Selenium 4.0.0-beta-1 and MS Edge SeleniumTools dependency
(AJ AUTOMATION)
6. Selenium WebDriver Setup on Microsoft Edge Browser
(Priyankaaz IT School)
Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated: 03/06/2023

Views: 6320

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.