IE特有の機能

これらは、Microsoft Internet Explorerブラウザに特有の機能と機能です。

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:

        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
            var options = new InternetExplorerOptions();
            options.AttachToEdgeChrome = true;
            options.EdgeExecutablePath = GetEdgeLocation();
            _driver = new InternetExplorerDriver(options);
Show full example
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;
using SeleniumDocs.TestSupport;

namespace SeleniumDocs.Browsers
{
    [TestClassCustom]
    [EnabledOnOs("WINDOWS")]
    public class InternetExplorerTest
    {
        private InternetExplorerDriver _driver;
        private string _logLocation;
        private string _tempPath;

        [TestCleanup]
        public void Cleanup()
        {
            if (_logLocation != null && File.Exists(_logLocation))
            {
                File.Delete(_logLocation);
            }
            if (_tempPath != null && File.Exists(_tempPath))
            {
                File.Delete(_tempPath);
            }
            _driver.Quit();
        }

        [TestMethod]
        public void BasicOptionsWin10()
        {
            var options = new InternetExplorerOptions();
            options.AttachToEdgeChrome = true;
            options.EdgeExecutablePath = GetEdgeLocation();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        public void BasicOptionsWin11()
        {
            var options = new InternetExplorerOptions();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToFile()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Console.WriteLine("Lines: {0}", lines);
            Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToConsole()
        {
            var stringWriter = new StringWriter();
            var originalOutput = Console.Out;
            Console.SetOut(stringWriter);

            var service = InternetExplorerDriverService.CreateDefaultService();

            //service.LogToConsole = true;

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(stringWriter.ToString().Contains("geckodriver	INFO	Listening on"));
            Console.SetOut(originalOutput);
            stringWriter.Dispose();
        }

        [TestMethod]
        public void LogsLevel()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            service.LoggingLevel = InternetExplorerDriverLogLevel.Warn;

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Assert.IsNotNull(lines.FirstOrDefault(line => line.Contains("Invalid capability setting: timeouts is type null")));
        }

        [TestMethod]
        public void SupportingFilesLocation()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();

            service.LibraryExtractionPath = GetTempDirectory();

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(File.Exists(GetTempDirectory() + "/IEDriver.tmp"));
        }

        private string GetLogLocation()
        {
            if (_logLocation == null || !File.Exists(_logLocation))
            {
                _logLocation = Path.GetTempFileName();
            }

            return _logLocation;
        }

        private string GetTempDirectory()
        {
            if (_tempPath == null || !File.Exists(_tempPath))
            {
                _tempPath = Path.GetTempPath();
            }

            return _tempPath;
        }

        private string GetEdgeLocation()
        {
            return Environment.GetEnvironmentVariable("EDGE_BIN");
        }
    }
}
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end

As of Internet Explorer Driver v4.5.0:

  • 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.

So, if IE is not on the system, you only need:

        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
            var options = new InternetExplorerOptions();
            _driver = new InternetExplorerDriver(options);
Show full example
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;
using SeleniumDocs.TestSupport;

namespace SeleniumDocs.Browsers
{
    [TestClassCustom]
    [EnabledOnOs("WINDOWS")]
    public class InternetExplorerTest
    {
        private InternetExplorerDriver _driver;
        private string _logLocation;
        private string _tempPath;

        [TestCleanup]
        public void Cleanup()
        {
            if (_logLocation != null && File.Exists(_logLocation))
            {
                File.Delete(_logLocation);
            }
            if (_tempPath != null && File.Exists(_tempPath))
            {
                File.Delete(_tempPath);
            }
            _driver.Quit();
        }

        [TestMethod]
        public void BasicOptionsWin10()
        {
            var options = new InternetExplorerOptions();
            options.AttachToEdgeChrome = true;
            options.EdgeExecutablePath = GetEdgeLocation();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        public void BasicOptionsWin11()
        {
            var options = new InternetExplorerOptions();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToFile()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Console.WriteLine("Lines: {0}", lines);
            Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToConsole()
        {
            var stringWriter = new StringWriter();
            var originalOutput = Console.Out;
            Console.SetOut(stringWriter);

            var service = InternetExplorerDriverService.CreateDefaultService();

            //service.LogToConsole = true;

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(stringWriter.ToString().Contains("geckodriver	INFO	Listening on"));
            Console.SetOut(originalOutput);
            stringWriter.Dispose();
        }

        [TestMethod]
        public void LogsLevel()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            service.LoggingLevel = InternetExplorerDriverLogLevel.Warn;

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Assert.IsNotNull(lines.FirstOrDefault(line => line.Contains("Invalid capability setting: timeouts is type null")));
        }

        [TestMethod]
        public void SupportingFilesLocation()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();

            service.LibraryExtractionPath = GetTempDirectory();

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(File.Exists(GetTempDirectory() + "/IEDriver.tmp"));
        }

        private string GetLogLocation()
        {
            if (_logLocation == null || !File.Exists(_logLocation))
            {
                _logLocation = Path.GetTempFileName();
            }

            return _logLocation;
        }

        private string GetTempDirectory()
        {
            if (_tempPath == null || !File.Exists(_tempPath))
            {
                _tempPath = Path.GetTempPath();
            }

            return _tempPath;
        }

        private string GetEdgeLocation()
        {
            return Environment.GetEnvironmentVariable("EDGE_BIN");
        }
    }
}
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
let driver = await new Builder()
.forBrowser('internet explorer')
.setIEOptions(options)
.build();
<p><a href=/documentation/about/contributing/#moving-examples>
<span class="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">Move Code</span></a></p>


val options = InternetExplorerOptions()
val driver = InternetExplorerDriver(options)

Here are a few common use cases with different capabilities:

fileUploadDialogTimeout

環境によっては、ファイルアップロードダイアログを開くときにInternet Explorerがタイムアウトする場合があります。 IEDriverのデフォルトのタイムアウトは1000ミリ秒ですが、fileUploadDialogTimeout capabilityを使用してタイムアウトを増やすことができます。

InternetExplorerOptions options = new InternetExplorerOptions();
options.waitForUploadDialogUpTo(Duration.ofSeconds(2));
WebDriver driver = new RemoteWebDriver(options);
  
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
var options = new InternetExplorerOptions();
options.FileUploadDialogTimeout = TimeSpan.FromMilliseconds(2000);
var driver = new RemoteWebDriver(options);
  
      @options.file_upload_dialog_timeout = 2000
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options().fileUploadDialogTimeout(2000);
let driver = await Builder()
          .setIeOptions(options)
          .build(); 
  
val options = InternetExplorerOptions()
options.waitForUploadDialogUpTo(Duration.ofSeconds(2))
val driver = RemoteWebDriver(options)
  

ensureCleanSession

この機能を true に設定すると、手動またはドライバーによって開始されたものを含め、 InternetExplorerの実行中のすべてのインスタンスのキャッシュ、ブラウザー履歴、およびCookieがクリアされます。 デフォルトでは、false に設定されています。

この機能を使用すると、ドライバーがIEブラウザーを起動する前にキャッシュがクリアされるまで待機するため、 ブラウザーの起動中にパフォーマンスが低下します。

このケイパビリティは、ブール値をパラメーターとして受け入れます。

InternetExplorerOptions options = new InternetExplorerOptions();
options.destructivelyEnsureCleanSession();
WebDriver driver = new RemoteWebDriver(options);
  
    options = webdriver.IeOptions()
    options.ensure_clean_session = True
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
var options = new InternetExplorerOptions();
options.EnsureCleanSession = true;
var driver = new RemoteWebDriver(options);
  
      @options.ensure_clean_session = true
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options().ensureCleanSession(true);
let driver = await Builder()
          .setIeOptions(options)
          .build(); 
  
val options = InternetExplorerOptions()
options.destructivelyEnsureCleanSession()
val driver = RemoteWebDriver(options)
  

ignoreZoomSetting

InternetExplorerドライバーは、ブラウザーのズームレベルが100%であることを想定しています。 それ以外の場合、ドライバーは例外をスローします。 このデフォルトの動作は、 ignoreZoomSettingtrue に設定することで無効にできます。

このケイパビリティは、ブール値をパラメーターとして受け入れます。

InternetExplorerOptions options = new InternetExplorerOptions();
options.ignoreZoomSettings();
WebDriver driver = new RemoteWebDriver(options);
  
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
var options = new InternetExplorerOptions();
options.IgnoreZoomLevel = true;
var driver = new RemoteWebDriver(options);
  
      @options.ignore_zoom_level = true
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options().ignoreZoomSetting(true);
let driver = await Builder()
          .setIeOptions(options)
          .build(); 
  
val options = InternetExplorerOptions()
options.ignoreZoomSettings()
val driver = RemoteWebDriver(options)
  

ignoreProtectedModeSettings

新しいIEセッションの起動中に 保護モード チェックをスキップするかどうか。

設定されておらず、 保護モード 設定がすべてのゾーンで同じでない場合、 ドライバーによって例外がスローされます。

ケイパビリティを true に設定すると、テストが不安定になったり、応答しなくなったり、 ブラウザがハングしたりする場合があります。 ただし、これはまだ2番目に良い選択であり、最初の選択は 常に 各ゾーンの保護モード設定を手動で実際に設定することです。 ユーザーがこのプロパティを使用している場合、「ベストエフォート」のみがサポートされます。

このケイパビリティは、ブール値をパラメーターとして受け入れます。

InternetExplorerOptions options = new InternetExplorerOptions();
options.introduceFlakinessByIgnoringSecurityDomains();
WebDriver driver = new RemoteWebDriver(options);
  
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
var driver = new RemoteWebDriver(options);
  
      @options.ignore_protected_mode_settings = true
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options().introduceFlakinessByIgnoringProtectedModeSettings(true);
let driver = await Builder()
          .setIeOptions(options)
          .build(); 
  
val options = InternetExplorerOptions()
options.introduceFlakinessByIgnoringSecurityDomains()
val driver = RemoteWebDriver(options)
  

silent

true に設定すると、このケイパビリティはIEDriverServerの診断出力を抑制します。

このケイパビリティは、ブール値をパラメーターとして受け入れます。

InternetExplorerOptions options = new InternetExplorerOptions();
options.setCapability("silent", true);
WebDriver driver = new InternetExplorerDriver(options);
  
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
InternetExplorerOptions options = new InternetExplorerOptions();
options.AddAdditionalInternetExplorerOption("silent", true);
IWebDriver driver = new InternetExplorerDriver(options);
  
      @options.silent = true
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const {Builder,By, Capabilities} = require('selenium-webdriver');
let caps = Capabilities.ie();
caps.set('silent', true);

(async function example() {
    let driver = await new Builder()
        .forBrowser('internet explorer')
        .withCapabilities(caps)
        .build();
    try {
        await driver.get('http://www.google.com/ncr');
    }
    finally {
        await driver.quit();
    }
})();
  
import org.openqa.selenium.Capabilities
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.ie.InternetExplorerOptions

fun main() {
    val options = InternetExplorerOptions()
    options.setCapability("silent", true)
    val driver = InternetExplorerDriver(options)
    try {
        driver.get("https://google.com/ncr")
        val caps = driver.getCapabilities()
        println(caps)
    } finally {
        driver.quit()
    }
}
  

IE Command-Line Options

Internet Explorerには、ブラウザーのトラブルシューティングと構成を可能にするいくつかのコマンドラインオプションが含まれています。

次に、サポートされているいくつかのコマンドラインオプションについて説明します。

  • -private : IEをプライベートブラウジングモードで起動するために使用されます。 これはIE 8以降のバージョンで機能します。

  • -k : Internet Explorerをキオスクモードで起動します。 ブラウザは、アドレスバー、ナビゲーションボタン、またはステータスバーを表示しない最大化されたウィンドウで開きます。

  • -extoff : アドオンなしモードでIEを起動します。 このオプションは、ブラウザーのアドオンに関する問題のトラブルシューティングに特に使用されます。 IE 7以降のバージョンで動作します。

注:コマンドライン引数が機能するためには、 forceCreateProcessApi を順番に有効にする必要があります。

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;

public class ieTest {
    public static void main(String[] args) {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.useCreateProcessApiToLaunchIe();
        options.addCommandSwitches("-k");
        InternetExplorerDriver driver = new InternetExplorerDriver(options);
        try {
            driver.get("https://google.com/ncr");
            Capabilities caps = driver.getCapabilities();
            System.out.println(caps);
        } finally {
            driver.quit();
        }
    }
}
  
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;

namespace ieTest {
 class Program {
  static void Main(string[] args) {
   InternetExplorerOptions options = new InternetExplorerOptions();
   options.ForceCreateProcessApi = true;
   options.BrowserCommandLineArguments = "-k";
   IWebDriver driver = new InternetExplorerDriver(options);
   driver.Url = "https://google.com/ncr";
  }
 }
}
  
      @options.add_argument('-k')
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options();
options.addBrowserCommandSwitches('-k');
options.addBrowserCommandSwitches('-private');
options.forceCreateProcessApi(true);

driver = await env.builder()
          .setIeOptions(options)
          .build();
  
import org.openqa.selenium.Capabilities
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.ie.InternetExplorerOptions

fun main() {
    val options = InternetExplorerOptions()
    options.useCreateProcessApiToLaunchIe()
    options.addCommandSwitches("-k")
    val driver = InternetExplorerDriver(options)
    try {
        driver.get("https://google.com/ncr")
        val caps = driver.getCapabilities()
        println(caps);
    } finally {
        driver.quit()
    }
}
  

forceCreateProcessApi

CreateProcess APIを使用してInternet Explorerを強制的に起動します。 デフォルト値はfalseです。

IE 8以降の場合、このオプションでは “TabProcGrowth” レジストリの値を0に設定する必要があります。

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerOptions;

public class ieTest {
    public static void main(String[] args) {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.useCreateProcessApiToLaunchIe();
        InternetExplorerDriver driver = new InternetExplorerDriver(options);
        try {
            driver.get("https://google.com/ncr");
            Capabilities caps = driver.getCapabilities();
            System.out.println(caps);
        } finally {
            driver.quit();
        }
    }
}
  
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.IE;

namespace ieTest {
 class Program {
  static void Main(string[] args) {
   InternetExplorerOptions options = new InternetExplorerOptions();
   options.ForceCreateProcessApi = true;
   IWebDriver driver = new InternetExplorerDriver(options);
   driver.Url = "https://google.com/ncr";
  }
 }
}
  
      @options.force_create_process_api = true
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
const ie = require('selenium-webdriver/ie');
let options = new ie.Options();
options.forceCreateProcessApi(true);

driver = await env.builder()
          .setIeOptions(options)
          .build();
  
import org.openqa.selenium.Capabilities
import org.openqa.selenium.ie.InternetExplorerDriver
import org.openqa.selenium.ie.InternetExplorerOptions

fun main() {
    val options = InternetExplorerOptions()
    options.useCreateProcessApiToLaunchIe()
    val driver = InternetExplorerDriver(options)
    try {
        driver.get("https://google.com/ncr")
        val caps = driver.getCapabilities()
        println(caps)
    } finally {
        driver.quit()
    }
}

  

Service

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:

Selenium v4.10

                .withLogFile(getLogLocation())
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}

Note: Java also allows setting file output by System Property:
Property key: InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY
Property value: String representing path to log file

    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()

Selenium v4.10

      service.log = file_name
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end

Console output

To change the logging output to display in the console as STDOUT:

Selenium v4.10

                .withLogOutput(System.out)
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}

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

Selenium v4.11

    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()

Selenium v4.10

      service.log = $stdout
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end

Log Level

There are 6 available log levels: FATAL, ERROR, WARN, INFO, DEBUG, and TRACE If logging output is specified, the default level is FATAL

                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}

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

    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
Show full example
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;
using SeleniumDocs.TestSupport;

namespace SeleniumDocs.Browsers
{
    [TestClassCustom]
    [EnabledOnOs("WINDOWS")]
    public class InternetExplorerTest
    {
        private InternetExplorerDriver _driver;
        private string _logLocation;
        private string _tempPath;

        [TestCleanup]
        public void Cleanup()
        {
            if (_logLocation != null && File.Exists(_logLocation))
            {
                File.Delete(_logLocation);
            }
            if (_tempPath != null && File.Exists(_tempPath))
            {
                File.Delete(_tempPath);
            }
            _driver.Quit();
        }

        [TestMethod]
        public void BasicOptionsWin10()
        {
            var options = new InternetExplorerOptions();
            options.AttachToEdgeChrome = true;
            options.EdgeExecutablePath = GetEdgeLocation();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        public void BasicOptionsWin11()
        {
            var options = new InternetExplorerOptions();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToFile()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Console.WriteLine("Lines: {0}", lines);
            Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToConsole()
        {
            var stringWriter = new StringWriter();
            var originalOutput = Console.Out;
            Console.SetOut(stringWriter);

            var service = InternetExplorerDriverService.CreateDefaultService();

            //service.LogToConsole = true;

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(stringWriter.ToString().Contains("geckodriver	INFO	Listening on"));
            Console.SetOut(originalOutput);
            stringWriter.Dispose();
        }

        [TestMethod]
        public void LogsLevel()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            service.LoggingLevel = InternetExplorerDriverLogLevel.Warn;

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Assert.IsNotNull(lines.FirstOrDefault(line => line.Contains("Invalid capability setting: timeouts is type null")));
        }

        [TestMethod]
        public void SupportingFilesLocation()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();

            service.LibraryExtractionPath = GetTempDirectory();

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(File.Exists(GetTempDirectory() + "/IEDriver.tmp"));
        }

        private string GetLogLocation()
        {
            if (_logLocation == null || !File.Exists(_logLocation))
            {
                _logLocation = Path.GetTempFileName();
            }

            return _logLocation;
        }

        private string GetTempDirectory()
        {
            if (_tempPath == null || !File.Exists(_tempPath))
            {
                _tempPath = Path.GetTempPath();
            }

            return _tempPath;
        }

        private string GetEdgeLocation()
        {
            return Environment.GetEnvironmentVariable("EDGE_BIN");
        }
    }
}

Selenium v4.10

      service.args << '-log-level=WARN'
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end

Supporting Files Path

                .withExtractPath(getTempDirectory())
Show full example
package dev.selenium.browsers;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.ie.InternetExplorerDriverLogLevel;
import org.openqa.selenium.ie.InternetExplorerDriverService;
import org.openqa.selenium.ie.InternetExplorerOptions;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;

@EnabledOnOs(OS.WINDOWS)
public class InternetExplorerTest {
    public InternetExplorerDriver driver;
    private File logLocation;
    private File tempDirectory;

    @AfterEach
    public void quit() {
        if (logLocation != null && logLocation.exists()) {
            logLocation.delete();
        }
        if (tempDirectory  != null && tempDirectory.exists()) {
            tempDirectory.delete();
        }

        driver.quit();
    }

    @Test
    public void basicOptionsWin10() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        options.attachToEdgeChrome();
        options.withEdgeExecutablePath(getEdgeLocation());
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void basicOptionsWin11() {
        InternetExplorerOptions options = new InternetExplorerOptions();
        driver = new InternetExplorerDriver(options);
    }

    @Test
    public void logsToFile() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogFile(getLogLocation())
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsToConsole() throws IOException {
        System.setOut(new PrintStream(getLogLocation()));

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogOutput(System.out)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));
    }

    @Test
    public void logsWithLevel() throws IOException {
        System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,
                getLogLocation().getAbsolutePath());

        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withLogLevel(InternetExplorerDriverLogLevel.WARN)
                .build();

        driver = new InternetExplorerDriver(service);

        String fileContent = new String(Files.readAllBytes(getLogLocation().toPath()));
        Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));
    }

    @Test
    public void supportingFilesLocation() throws IOException {
        InternetExplorerDriverService service = new InternetExplorerDriverService.Builder()
                .withExtractPath(getTempDirectory())
                .build();

        driver = new InternetExplorerDriver(service);
        Assertions.assertTrue(new File(getTempDirectory() + "/IEDriver.tmp").exists());
    }

    private File getLogLocation() throws IOException {
        if (logLocation == null || !logLocation.exists()) {
            logLocation = File.createTempFile("iedriver-", ".log");
        }

        return logLocation;
    }

    private File getTempDirectory() throws IOException {
        if (tempDirectory == null || !tempDirectory.exists()) {
            tempDirectory = Files.createTempDirectory("supporting-").toFile();
        }

        return tempDirectory;
    }

    private String getEdgeLocation() {
        return System.getenv("EDGE_BIN");
    }
}
**Note**: Java also allows setting log level by System Property:\ Property key: `InternetExplorerDriverService.IE_DRIVER_EXTRACT_PATH_PROPERTY`\ Property value: String representing path to supporting files directory

Selenium v4.11

    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)
Show full example
import os
import subprocess
import sys

import pytest
from selenium import webdriver


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win10(edge_bin):
    options = webdriver.IeOptions()
    options.attach_to_edge_chrome = True
    options.edge_executable_path = edge_bin
    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_basic_options_win11():
    options = webdriver.IeOptions()
    driver = webdriver.Ie(options=options)

    driver.quit()

@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_file_upload_timeout():
    options = webdriver.IeOptions()
    options.file_upload_timeout = 2000

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ensure_clean_session():
    options = webdriver.IeOptions()
    options.ensure_clean_session = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_zoom_level():
    options = webdriver.IeOptions()
    options.ignore_zoom_level = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_ignore_protected_mode_settings():
    options = webdriver.IeOptions()
    options.ignore_protected_mode_settings = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_silent():
    service = webdriver.IeService(service_args=["--silent"])
    driver = webdriver.Ie(service=service)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_cmd_options():
    options = webdriver.IeOptions()
    options.add_argument("-private")

    driver = webdriver.Ie(options=options)

    driver.quit()

# Skipping this as it fails on Windows because the value of registry setting in 
# HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\TabProcGrowth must be '0' 
@pytest.mark.skip
def test_force_create_process_api():
    options = webdriver.IeOptions()
    options.force_create_process_api = True

    driver = webdriver.Ie(options=options)

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_file(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="INFO")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Starting WebDriver server" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_to_stdout(capfd):
    service = webdriver.IeService(log_output=subprocess.STDOUT)

    driver = webdriver.Ie(service=service)

    out, err = capfd.readouterr()
    assert "Started InternetExplorerDriver server" in out

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_log_level(log_path):
    service = webdriver.IeService(log_output=log_path, log_level="WARN")

    driver = webdriver.Ie(service=service)

    with open(log_path, "r") as fp:
        assert "Started InternetExplorerDriver server (32-bit)" in fp.readline()

    driver.quit()


@pytest.mark.skipif(sys.platform != "win32", reason="requires Windows")
def test_supporting_files(temp_dir):
    service = webdriver.IeService(service_args=["–extract-path=" + temp_dir])

    driver = webdriver.Ie(service=service)

    driver.quit()
Show full example
using System;
using System.IO;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.IE;
using SeleniumDocs.TestSupport;

namespace SeleniumDocs.Browsers
{
    [TestClassCustom]
    [EnabledOnOs("WINDOWS")]
    public class InternetExplorerTest
    {
        private InternetExplorerDriver _driver;
        private string _logLocation;
        private string _tempPath;

        [TestCleanup]
        public void Cleanup()
        {
            if (_logLocation != null && File.Exists(_logLocation))
            {
                File.Delete(_logLocation);
            }
            if (_tempPath != null && File.Exists(_tempPath))
            {
                File.Delete(_tempPath);
            }
            _driver.Quit();
        }

        [TestMethod]
        public void BasicOptionsWin10()
        {
            var options = new InternetExplorerOptions();
            options.AttachToEdgeChrome = true;
            options.EdgeExecutablePath = GetEdgeLocation();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        public void BasicOptionsWin11()
        {
            var options = new InternetExplorerOptions();
            _driver = new InternetExplorerDriver(options);
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToFile()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Console.WriteLine("Lines: {0}", lines);
            Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));
        }

        [TestMethod]
        [Ignore("Not implemented")]
        public void LogsToConsole()
        {
            var stringWriter = new StringWriter();
            var originalOutput = Console.Out;
            Console.SetOut(stringWriter);

            var service = InternetExplorerDriverService.CreateDefaultService();

            //service.LogToConsole = true;

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(stringWriter.ToString().Contains("geckodriver	INFO	Listening on"));
            Console.SetOut(originalOutput);
            stringWriter.Dispose();
        }

        [TestMethod]
        public void LogsLevel()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();
            service.LogFile = GetLogLocation();

            service.LoggingLevel = InternetExplorerDriverLogLevel.Warn;

            _driver = new InternetExplorerDriver(service);
            _driver.Quit(); // Close the Service log file before reading
            var lines = File.ReadLines(GetLogLocation());
            Assert.IsNotNull(lines.FirstOrDefault(line => line.Contains("Invalid capability setting: timeouts is type null")));
        }

        [TestMethod]
        public void SupportingFilesLocation()
        {
            var service = InternetExplorerDriverService.CreateDefaultService();

            service.LibraryExtractionPath = GetTempDirectory();

            _driver = new InternetExplorerDriver(service);
            Assert.IsTrue(File.Exists(GetTempDirectory() + "/IEDriver.tmp"));
        }

        private string GetLogLocation()
        {
            if (_logLocation == null || !File.Exists(_logLocation))
            {
                _logLocation = Path.GetTempFileName();
            }

            return _logLocation;
        }

        private string GetTempDirectory()
        {
            if (_tempPath == null || !File.Exists(_tempPath))
            {
                _tempPath = Path.GetTempPath();
            }

            return _tempPath;
        }

        private string GetEdgeLocation()
        {
            return Environment.GetEnvironmentVariable("EDGE_BIN");
        }
    }
}

Selenium v4.8

      service.args << "–extract-path=#{root_directory}"
Show full example
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Internet Explorer', exclusive: {platform: :windows} do
  describe 'Options' do
    let(:edge_location) { ENV.fetch('EDGE_BIN', nil) }
    let(:url) { 'https://www.selenium.dev/selenium/web/' }

    before do
      @options = Selenium::WebDriver::IE::Options.new
      @options.attach_to_edge_chrome = true
      @options.edge_executable_path = edge_location
    end

    it 'basic options Win10' do
      options = Selenium::WebDriver::IE::Options.new
      options.attach_to_edge_chrome = true
      options.edge_executable_path = edge_location
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'basic options Win11' do
      options = Selenium::WebDriver::Options.ie
      @driver = Selenium::WebDriver.for :ie, options: options
    end

    it 'sets the file upload dialog timeout' do
      @options.file_upload_dialog_timeout = 2000
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ensures a clean session' do
      @options.ensure_clean_session = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the zoom setting' do
      @options.ignore_zoom_level = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'ignores the protected mode settings' do
      @options.ignore_protected_mode_settings = true
      driver = Selenium::WebDriver.for(:ie, options: @options)
      driver.quit
    end

    it 'adds the silent option', skip: 'This capability will be added on the release 4.22.0' do
      @options.silent = true
      expect(@options.silent).to be_truthy
    end

    it 'sets the command line options' do
      @options.add_argument('-k')
      Selenium::WebDriver.for(:ie, options: @options)
    end

    it 'launches ie with the create process api', skip: 'When using with IE 8 or higher, it needs a registry value' do
      @options.force_create_process_api = true
      Selenium::WebDriver.for(:ie, options: @options)
      expect(@options.instance_variable_get(:@options)['force_create_process_api'])
        .to eq({force_create_process_api: true})
    end
  end

  describe 'Service' do
    let(:file_name) { Tempfile.new('iedriver').path }
    let(:root_directory) { Dir.mktmpdir }

    after do
      FileUtils.rm_f(file_name)
      FileUtils.remove_entry root_directory
    end

    it 'logs to file' do
      service = Selenium::WebDriver::Service.ie

      service.log = file_name

      @driver = Selenium::WebDriver.for :ie, service: service
      expect(File.readlines(file_name).first).to include('Started InternetExplorerDriver server')
    end

    it 'logs to console' do
      service = Selenium::WebDriver::Service.ie

      service.log = $stdout

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Started InternetExplorerDriver server/).to_stdout_from_any_process
    end

    it 'sets log level' do
      service = Selenium::WebDriver::Service.ie
      service.log = $stdout

      service.args << '-log-level=WARN'

      expect {
        @driver = Selenium::WebDriver.for :ie, service: service
      }.to output(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_process
    end

    it 'sets location for supporting files' do
      service = Selenium::WebDriver::Service.ie

      service.args << "–extract-path=#{root_directory}"

      @driver = Selenium::WebDriver.for :ie, service: service
    end
  end
end
最終更新 December 20, 2024: [py] fix ie code line (#2107) (add39da644)