As of June 2022, Selenium officially no longer supports standalone Internet Explorer.
The Internet Explorer driver still supports running Microsoft Edge in “IE Compatibility Mode.”
Special considerations
The IE Driver is the only driver maintained by the Selenium Project directly.
While binaries for both the 32-bit and 64-bit
versions of Internet Explorer are available, there are some
known limitations
with the 64-bit driver. As such it is recommended to use the 32-bit driver.
Additional information about using Internet Explorer can be found on the
IE Driver Server page
Options
Starting a Microsoft Edge browser in Internet Explorer Compatibility mode with basic defined options looks like this:
If IE is not present on the system (default in Windows 11), you do not need to
use the two parameters above. IE Driver will use Edge and will automatically locate it.
If IE and Edge are both present on the system, you only need to set attaching to Edge,
IE Driver will automatically locate Edge on your system.
<p><ahref=/documentation/about/contributing/#moving-examples><spanclass="selenium-badge-code"data-bs-toggle="tooltip"data-bs-placement="right"title="One or more of these examples need to be implemented in the examples directory; click for details in the contribution guide">MoveCode</span></a></p>valoptions=InternetExplorerOptions()valdriver=InternetExplorerDriver(options)
Here are a few common use cases with different capabilities:
Service settings common to all browsers are described on the Service page.
Log output
Getting driver logs can be helpful for debugging various issues. The Service class lets you
direct where the logs will go. Logging output is ignored unless the user directs it somewhere.
File output
To change the logging output to save to a specific file:
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriverEDGE_BINARY=os.getenv("EDGE_BINARY")@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10():options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=EDGE_BINARYdriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='INFO')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skip(reason="this is not supported, yet")deftest_log_to_stdout(capfd):service=webdriver.ie.service.Service(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='WARN')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert'Invalid capability setting: timeouts is type null'infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.ie.service.Service(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
packagedev.selenium.browsers;importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.Assertions;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.condition.EnabledOnOs;importorg.junit.jupiter.api.condition.OS;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.ie.InternetExplorerDriverLogLevel;importorg.openqa.selenium.ie.InternetExplorerDriverService;importorg.openqa.selenium.ie.InternetExplorerOptions;importjava.io.File;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.Files;@EnabledOnOs(OS.WINDOWS)publicclassInternetExplorerTest{publicInternetExplorerDriverdriver;privateFilelogLocation;privateFiletempDirectory;@AfterEachpublicvoidquit(){if(logLocation!=null&&logLocation.exists()){logLocation.delete();}if(tempDirectory!=null&&tempDirectory.exists()){tempDirectory.delete();}driver.quit();}@TestpublicvoidbasicOptionsWin10(){InternetExplorerOptionsoptions=newInternetExplorerOptions();options.attachToEdgeChrome();options.withEdgeExecutablePath(System.getProperty("webdriver.edge.binary"));driver=newInternetExplorerDriver(options);}@TestpublicvoidbasicOptionsWin11(){InternetExplorerOptionsoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);}@TestpublicvoidlogsToFile()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogFile(getLogLocation()).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsToConsole()throwsIOException{System.setOut(newPrintStream(getLogLocation()));InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogOutput(System.out).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsWithLevel()throwsIOException{System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,getLogLocation().getAbsolutePath());InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogLevel(InternetExplorerDriverLogLevel.WARN).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));}@TestpublicvoidsupportingFilesLocation()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withExtractPath(getTempDirectory()).build();driver=newInternetExplorerDriver(service);Assertions.assertTrue(newFile(getTempDirectory()+"/IEDriver.tmp").exists());}privateFilegetLogLocation()throwsIOException{if(logLocation==null||!logLocation.exists()){logLocation=File.createTempFile("iedriver-",".log");}returnlogLocation;}privateFilegetTempDirectory()throwsIOException{if(tempDirectory==null||!tempDirectory.exists()){tempDirectory=Files.createTempDirectory("supporting-").toFile();}returntempDirectory;}}
Note: Java also allows setting console output by System Property; Property key: InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY Property value: DriverService.LOG_STDOUT or DriverService.LOG_STDERR
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriverEDGE_BINARY=os.getenv("EDGE_BINARY")@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10():options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=EDGE_BINARYdriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='INFO')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skip(reason="this is not supported, yet")deftest_log_to_stdout(capfd):service=webdriver.ie.service.Service(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='WARN')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert'Invalid capability setting: timeouts is type null'infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.ie.service.Service(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
packagedev.selenium.browsers;importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.Assertions;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.condition.EnabledOnOs;importorg.junit.jupiter.api.condition.OS;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.ie.InternetExplorerDriverLogLevel;importorg.openqa.selenium.ie.InternetExplorerDriverService;importorg.openqa.selenium.ie.InternetExplorerOptions;importjava.io.File;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.Files;@EnabledOnOs(OS.WINDOWS)publicclassInternetExplorerTest{publicInternetExplorerDriverdriver;privateFilelogLocation;privateFiletempDirectory;@AfterEachpublicvoidquit(){if(logLocation!=null&&logLocation.exists()){logLocation.delete();}if(tempDirectory!=null&&tempDirectory.exists()){tempDirectory.delete();}driver.quit();}@TestpublicvoidbasicOptionsWin10(){InternetExplorerOptionsoptions=newInternetExplorerOptions();options.attachToEdgeChrome();options.withEdgeExecutablePath(System.getProperty("webdriver.edge.binary"));driver=newInternetExplorerDriver(options);}@TestpublicvoidbasicOptionsWin11(){InternetExplorerOptionsoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);}@TestpublicvoidlogsToFile()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogFile(getLogLocation()).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsToConsole()throwsIOException{System.setOut(newPrintStream(getLogLocation()));InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogOutput(System.out).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsWithLevel()throwsIOException{System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,getLogLocation().getAbsolutePath());InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogLevel(InternetExplorerDriverLogLevel.WARN).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));}@TestpublicvoidsupportingFilesLocation()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withExtractPath(getTempDirectory()).build();driver=newInternetExplorerDriver(service);Assertions.assertTrue(newFile(getTempDirectory()+"/IEDriver.tmp").exists());}privateFilegetLogLocation()throwsIOException{if(logLocation==null||!logLocation.exists()){logLocation=File.createTempFile("iedriver-",".log");}returnlogLocation;}privateFilegetTempDirectory()throwsIOException{if(tempDirectory==null||!tempDirectory.exists()){tempDirectory=Files.createTempDirectory("supporting-").toFile();}returntempDirectory;}}
Note: Java also allows setting log level by System Property: Property key: InternetExplorerDriverService.IE_DRIVER_LOGLEVEL_PROPERTY Property value: String representation of InternetExplorerDriverLogLevel.DEBUG.toString() enum
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriverEDGE_BINARY=os.getenv("EDGE_BINARY")@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10():options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=EDGE_BINARYdriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='INFO')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skip(reason="this is not supported, yet")deftest_log_to_stdout(capfd):service=webdriver.ie.service.Service(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='WARN')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert'Invalid capability setting: timeouts is type null'infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.ie.service.Service(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
usingSystem;usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{ [TestClassCustom] [EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriverdriver;privatestring_logLocation;privatestring_tempPath; [TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}driver.Quit();} [TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=Environment.GetEnvironmentVariable("EDGE_BINARY");driver=newInternetExplorerDriver(options);} [TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();driver=newInternetExplorerDriver(service);driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("geckodriver INFO Listening on")));} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();} [TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;driver=newInternetExplorerDriver(service);driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));} [TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}}}
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriverEDGE_BINARY=os.getenv("EDGE_BINARY")@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10():options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=EDGE_BINARYdriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='INFO')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skip(reason="this is not supported, yet")deftest_log_to_stdout(capfd):service=webdriver.ie.service.Service(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.ie.service.Service(log_file=log_path,log_level='WARN')driver=webdriver.Ie(service=service)withopen(log_path,'r')asfp:assert'Invalid capability setting: timeouts is type null'infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.ie.service.Service(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
usingSystem;usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{ [TestClassCustom] [EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriverdriver;privatestring_logLocation;privatestring_tempPath; [TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}driver.Quit();} [TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=Environment.GetEnvironmentVariable("EDGE_BINARY");driver=newInternetExplorerDriver(options);} [TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();driver=newInternetExplorerDriver(service);driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("geckodriver INFO Listening on")));} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();} [TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;driver=newInternetExplorerDriver(service);driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));} [TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}}}