Jump to content
Microsoft Windows Bulletin Board

Test IE mode in Microsoft Edge with Internet Explorer Driver


Recommended Posts

Guest Microsoft Edge Team
Posted

In collaboration with our friends in the Selenium project, the Microsoft Edge team is excited to announce that you can now test Internet Explorer mode in Microsoft Edge with Internet Explorer Driver. With just a few changes to an existing test that runs against Internet Explorer, you can get your tests running in Internet Explorer (IE) mode in Edge. By running your tests in IE mode, you will be able to verify that any legacy web content that runs in Internet Explorer will work as expected in IE mode in Microsoft Edge.

[HEADING=1]Validate IE mode for legacy websites and apps[/HEADING]

IE mode is a feature in Microsoft Edge for organizations that still need Internet Explorer 11 for backward compatibility of business-critical legacy websites or apps. To learn more about IE mode, read What is Internet Explorer (IE) mode?. Starting June 15, 2022, Internet Explorer 11 will no longer be supported on certain versions of Windows 10. For more information, read Internet Explorer 11 desktop app requirement FAQ. We recommend that organizations that still depend on IE11 transition to the Microsoft Edge browser, which supports rendering modern and legacy web content. You can learn more about deploying Microsoft Edge and setting up a Site List in our docs. To prepare for June 15, you can now use Internet Explorer Driver to validate that IE mode is the right solution for your business-critical legacy websites or apps.

[HEADING=1]What you’ll need to get started[/HEADING]

To start running tests in IE mode in Edge, you need the following:

  1. Microsoft Edge
  2. Selenium 4 or later language bindings
  3. Internet Explorer Driver version 4.0.0.0 or later

Once you download IE Driver, ensure that you set it up correctly with Selenium’s Required Configuration.

[HEADING=1]Code samples[/HEADING]

The following C#, Python, Java, and JavaScript code samples assume you are using the Selenium framework but you can use any library, framework, or programming language that supports WebDriver. To accomplish the same tasks using another framework, consult the documentation for your framework of choice. These code samples launch Microsoft Edge in IE mode, navigate to What are these soldiers celebrating? and runs a search for “IE mode”.

[HEADING=2]C#[/HEADING]

 

using System;

using OpenQA.Selenium;

using OpenQA.Selenium.IE;

 

namespace IEDriverSample

{

class Program

{

static void Main(string[] args)

{

var ieOptions = new InternetExplorerOptions();

ieOptions.AttachToEdgeChrome = true;

//change the path accordingly

ieOptions.EdgeExecutablePath = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe";

 

var driver = new InternetExplorerDriver(ieOptions);

driver.Url = "What are these soldiers celebrating?";

driver.FindElement(By.Id("sb_form_q")).SendKeys("IE mode");

driver.FindElement(By.Id("sb_form")).Submit();

 

driver.Quit();

}

}

}

[HEADING=2]Python[/HEADING]

 

from selenium import webdriver

from selenium.webdriver.common.by import By

from selenium.webdriver.common.keys import Keys

 

ie_options = webdriver.IeOptions()

ie_options.attach_to_edge_chrome = True

ie_options.edge_executable_path = "C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"

 

driver = webdriver.Ie(options=ie_options)

 

driver.get("What are these soldiers celebrating?")

elem = driver.find_element(By.ID, 'sb_form_q')

elem.send_keys('IE mode' + Keys.RETURN)

 

driver.quit()

[HEADING=2]Java[/HEADING]

 

import org.openqa.selenium.By;

import org.openqa.selenium.Keys;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.ie.InternetExplorerDriver;

import org.openqa.selenium.ie.InternetExplorerOptions;

 

public class IEDriverSample {

public static void main(String[] args) {

InternetExplorerOptions ieOptions = new InternetExplorerOptions();

ieOptions.attachToEdgeChrome();

ieOptions.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe");

 

WebDriver driver = new InternetExplorerDriver(ieOptions);

 

driver.get("What are these soldiers celebrating?");

WebElement elem = driver.findElement(By.id("sb_form_q"));

elem.sendKeys("IE mode", Keys.RETURN);

 

driver.close();

}

}

[HEADING=2]JavaScript[/HEADING]

 

const {Builder, By, Key, until} = require('selenium-webdriver');

const {Options} = require('selenium-webdriver/ie');

 

(async () => {

let ieOptions = new Options();

ieOptions.setEdgeChromium(true);

ieOptions.setEdgePath('C:/Program Files (x86)/Microsoft/Edge/Application/msedge.exe');

 

let driver = await new Builder().

forBrowser('ie').

setIeOptions(ieOptions).

build();

try {

await driver.get('http://www.bing.com');

let elem = await driver.findElement(By.id('sb_form_q'));

await elem.sendKeys('IE mode', Key.RETURN);

await driver.wait(until.titleIs('IE mode - Bing'), 1000);

} finally {

await driver.quit();

}

})();

For more information on automating IE mode in Edge, head to our docs.

[HEADING=1]Feedback[/HEADING]

If you run into any issues with the code samples, docs, or instructions in this blog post, you can follow up with the Microsoft Edge team on Twitter @EdgeDevTools or by submitting feedback in the Microsoft Edge browser (Alt+Shift+I). If you are experiencing problems with IE Driver itself or are observing differences between IE Driver version 4.0.0.0 and earlier versions, consult the Known limitations section of our docs. We have included workarounds for some of these known limitations. If you are still blocked, refer to the open issues in the Selenium repo and open a new issue if needed. Finally, if you are noticing rendering differences between IE mode and the Internet Explorer 11 desktop app, refer to the IE mode troubleshooting and FAQ. If you still need help, you can contact the free App Assure program. – Zoher Ghadyali, Senior Program Manager, Microsoft Edge

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...