importsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["–silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full//examples/python/tests/browsers/test_internet_explorer.py#L11-L14" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{[TestClassCustom][EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriver_driver;privatestring_logLocation;privatestring_tempPath;[TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}_driver.Quit();}[TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=GetEdgeLocation();_driver=newInternetExplorerDriver(options);}[TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();_driver=newInternetExplorerDriver(options);}[TestMethod][Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Console.WriteLine("Lines: {0}",lines);Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));}[TestMethod][Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;_driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();}[TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));}[TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();_driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}privatestringGetEdgeLocation(){returnEnvironment.GetEnvironmentVariable("EDGE_BIN");}}}
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full//examples/dotnet/SeleniumDocs/Browsers/InternetExplorerTest.cs#L35-L38" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
1621
Show full example
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["–silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full//examples/python/tests/browsers/test_internet_explorer.py#L21-L22" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{[TestClassCustom][EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriver_driver;privatestring_logLocation;privatestring_tempPath;[TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}_driver.Quit();}[TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=GetEdgeLocation();_driver=newInternetExplorerDriver(options);}[TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();_driver=newInternetExplorerDriver(options);}[TestMethod][Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Console.WriteLine("Lines: {0}",lines);Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));}[TestMethod][Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;_driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();}[TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));}[TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();_driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}privatestringGetEdgeLocation(){returnEnvironment.GetEnvironmentVariable("EDGE_BIN");}}}
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full//examples/dotnet/SeleniumDocs/Browsers/InternetExplorerTest.cs#L44-L45" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
2326
Show full example
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
<p><ahref=/documentation/about/contributing/#moving-examples><spanclass="selenium-badge-code"data-bs-toggle="tooltip"data-bs-placement="right"title="One or more of these examples need to be implemented in the examples directory; click for details in the contribution guide">MoveCode</span></a></p>valoptions=InternetExplorerOptions()valdriver=InternetExplorerDriver(options)
以下是几种具有不同功能的常见用例:
fileUploadDialogTimeout
在某些环境中, 当打开文件上传对话框时, Internet Explorer可能会超时. IEDriver的默认超时为1000毫秒, 但您可以使用fileUploadDialogTimeout功能来增加超时时间.
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.Assertions;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.condition.EnabledOnOs;importorg.junit.jupiter.api.condition.OS;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.ie.InternetExplorerDriverLogLevel;importorg.openqa.selenium.ie.InternetExplorerDriverService;importorg.openqa.selenium.ie.InternetExplorerOptions;importjava.io.File;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.Files;@EnabledOnOs(OS.WINDOWS)publicclassInternetExplorerTest{publicInternetExplorerDriverdriver;privateFilelogLocation;privateFiletempDirectory;@AfterEachpublicvoidquit(){if(logLocation!=null&&logLocation.exists()){logLocation.delete();}if(tempDirectory!=null&&tempDirectory.exists()){tempDirectory.delete();}driver.quit();}@TestpublicvoidbasicOptionsWin10(){InternetExplorerOptionsoptions=newInternetExplorerOptions();options.attachToEdgeChrome();options.withEdgeExecutablePath(getEdgeLocation());driver=newInternetExplorerDriver(options);}@TestpublicvoidbasicOptionsWin11(){InternetExplorerOptionsoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);}@TestpublicvoidlogsToFile()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogFile(getLogLocation()).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsToConsole()throwsIOException{System.setOut(newPrintStream(getLogLocation()));InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogOutput(System.out).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsWithLevel()throwsIOException{System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,getLogLocation().getAbsolutePath());InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogLevel(InternetExplorerDriverLogLevel.WARN).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));}@TestpublicvoidsupportingFilesLocation()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withExtractPath(getTempDirectory()).build();driver=newInternetExplorerDriver(service);Assertions.assertTrue(newFile(getTempDirectory()+"/IEDriver.tmp").exists());}privateFilegetLogLocation()throwsIOException{if(logLocation==null||!logLocation.exists()){logLocation=File.createTempFile("iedriver-",".log");}returnlogLocation;}privateFilegetTempDirectory()throwsIOException{if(tempDirectory==null||!tempDirectory.exists()){tempDirectory=Files.createTempDirectory("supporting-").toFile();}returntempDirectory;}privateStringgetEdgeLocation(){returnSystem.getenv("EDGE_BIN");}}
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full/examples/java/src/test/java/dev/selenium/browsers/InternetExplorerTest.java#L53" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
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
96100
Show full example
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.Assertions;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.condition.EnabledOnOs;importorg.junit.jupiter.api.condition.OS;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.ie.InternetExplorerDriverLogLevel;importorg.openqa.selenium.ie.InternetExplorerDriverService;importorg.openqa.selenium.ie.InternetExplorerOptions;importjava.io.File;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.Files;@EnabledOnOs(OS.WINDOWS)publicclassInternetExplorerTest{publicInternetExplorerDriverdriver;privateFilelogLocation;privateFiletempDirectory;@AfterEachpublicvoidquit(){if(logLocation!=null&&logLocation.exists()){logLocation.delete();}if(tempDirectory!=null&&tempDirectory.exists()){tempDirectory.delete();}driver.quit();}@TestpublicvoidbasicOptionsWin10(){InternetExplorerOptionsoptions=newInternetExplorerOptions();options.attachToEdgeChrome();options.withEdgeExecutablePath(getEdgeLocation());driver=newInternetExplorerDriver(options);}@TestpublicvoidbasicOptionsWin11(){InternetExplorerOptionsoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);}@TestpublicvoidlogsToFile()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogFile(getLogLocation()).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsToConsole()throwsIOException{System.setOut(newPrintStream(getLogLocation()));InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogOutput(System.out).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsWithLevel()throwsIOException{System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,getLogLocation().getAbsolutePath());InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogLevel(InternetExplorerDriverLogLevel.WARN).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));}@TestpublicvoidsupportingFilesLocation()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withExtractPath(getTempDirectory()).build();driver=newInternetExplorerDriver(service);Assertions.assertTrue(newFile(getTempDirectory()+"/IEDriver.tmp").exists());}privateFilegetLogLocation()throwsIOException{if(logLocation==null||!logLocation.exists()){logLocation=File.createTempFile("iedriver-",".log");}returnlogLocation;}privateFilegetTempDirectory()throwsIOException{if(tempDirectory==null||!tempDirectory.exists()){tempDirectory=Files.createTempDirectory("supporting-").toFile();}returntempDirectory;}privateStringgetEdgeLocation(){returnSystem.getenv("EDGE_BIN");}}
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full/examples/java/src/test/java/dev/selenium/browsers/InternetExplorerTest.java#L67" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
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
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importorg.junit.jupiter.api.AfterEach;importorg.junit.jupiter.api.Assertions;importorg.junit.jupiter.api.Test;importorg.junit.jupiter.api.condition.EnabledOnOs;importorg.junit.jupiter.api.condition.OS;importorg.openqa.selenium.ie.InternetExplorerDriver;importorg.openqa.selenium.ie.InternetExplorerDriverLogLevel;importorg.openqa.selenium.ie.InternetExplorerDriverService;importorg.openqa.selenium.ie.InternetExplorerOptions;importjava.io.File;importjava.io.IOException;importjava.io.PrintStream;importjava.nio.file.Files;@EnabledOnOs(OS.WINDOWS)publicclassInternetExplorerTest{publicInternetExplorerDriverdriver;privateFilelogLocation;privateFiletempDirectory;@AfterEachpublicvoidquit(){if(logLocation!=null&&logLocation.exists()){logLocation.delete();}if(tempDirectory!=null&&tempDirectory.exists()){tempDirectory.delete();}driver.quit();}@TestpublicvoidbasicOptionsWin10(){InternetExplorerOptionsoptions=newInternetExplorerOptions();options.attachToEdgeChrome();options.withEdgeExecutablePath(getEdgeLocation());driver=newInternetExplorerDriver(options);}@TestpublicvoidbasicOptionsWin11(){InternetExplorerOptionsoptions=newInternetExplorerOptions();driver=newInternetExplorerDriver(options);}@TestpublicvoidlogsToFile()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogFile(getLogLocation()).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsToConsole()throwsIOException{System.setOut(newPrintStream(getLogLocation()));InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogOutput(System.out).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Started InternetExplorerDriver server"));}@TestpublicvoidlogsWithLevel()throwsIOException{System.setProperty(InternetExplorerDriverService.IE_DRIVER_LOGFILE_PROPERTY,getLogLocation().getAbsolutePath());InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withLogLevel(InternetExplorerDriverLogLevel.WARN).build();driver=newInternetExplorerDriver(service);StringfileContent=newString(Files.readAllBytes(getLogLocation().toPath()));Assertions.assertTrue(fileContent.contains("Invalid capability setting: timeouts is type null"));}@TestpublicvoidsupportingFilesLocation()throwsIOException{InternetExplorerDriverServiceservice=newInternetExplorerDriverService.Builder().withExtractPath(getTempDirectory()).build();driver=newInternetExplorerDriver(service);Assertions.assertTrue(newFile(getTempDirectory()+"/IEDriver.tmp").exists());}privateFilegetLogLocation()throwsIOException{if(logLocation==null||!logLocation.exists()){logLocation=File.createTempFile("iedriver-",".log");}returnlogLocation;}privateFilegetTempDirectory()throwsIOException{if(tempDirectory==null||!tempDirectory.exists()){tempDirectory=Files.createTempDirectory("supporting-").toFile();}returntempDirectory;}privateStringgetEdgeLocation(){returnSystem.getenv("EDGE_BIN");}}
<div class="text-end pb-2 mt-2">
<a href="https://github.com/SeleniumHQ/seleniumhq.github.io/blob/display_full/examples/java/src/test/java/dev/selenium/browsers/InternetExplorerTest.java#L82" target="_blank">
<i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong>
</a>
</div>
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
120124
Show full example
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
usingSystem;usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{ [TestClassCustom] [EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriver_driver;privatestring_logLocation;privatestring_tempPath; [TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}_driver.Quit();} [TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=GetEdgeLocation();_driver=newInternetExplorerDriver(options);} [TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();_driver=newInternetExplorerDriver(options);} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Console.WriteLine("Lines: {0}",lines);Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;_driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();} [TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));} [TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();_driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}privatestringGetEdgeLocation(){returnEnvironment.GetEnvironmentVariable("EDGE_BIN");}}}
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend
importosimportsubprocessimportsysimportpytestfromseleniumimportwebdriver@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win10(edge_bin):options=webdriver.IeOptions()options.attach_to_edge_chrome=Trueoptions.edge_executable_path=edge_bindriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_basic_options_win11():options=webdriver.IeOptions()driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_file_upload_timeout():options=webdriver.IeOptions()options.file_upload_timeout=2000driver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ensure_clean_session():options=webdriver.IeOptions()options.ensure_clean_session=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_zoom_level():options=webdriver.IeOptions()options.ignore_zoom_level=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_ignore_protected_mode_settings():options=webdriver.IeOptions()options.ignore_protected_mode_settings=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_silent():service=webdriver.IeService(service_args=["--silent"])driver=webdriver.Ie(service=service)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_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.skipdeftest_force_create_process_api():options=webdriver.IeOptions()options.force_create_process_api=Truedriver=webdriver.Ie(options=options)driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_file(log_path):service=webdriver.IeService(log_output=log_path,log_level="INFO")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Starting WebDriver server"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_to_stdout(capfd):service=webdriver.IeService(log_output=subprocess.STDOUT)driver=webdriver.Ie(service=service)out,err=capfd.readouterr()assert"Started InternetExplorerDriver server"inoutdriver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_log_level(log_path):service=webdriver.IeService(log_output=log_path,log_level="WARN")driver=webdriver.Ie(service=service)withopen(log_path,"r")asfp:assert"Started InternetExplorerDriver server (32-bit)"infp.readline()driver.quit()@pytest.mark.skipif(sys.platform!="win32",reason="requires Windows")deftest_supporting_files(temp_dir):service=webdriver.IeService(service_args=["–extract-path="+temp_dir])driver=webdriver.Ie(service=service)driver.quit()
usingSystem;usingSystem.IO;usingSystem.Linq;usingMicrosoft.VisualStudio.TestTools.UnitTesting;usingOpenQA.Selenium.IE;usingSeleniumDocs.TestSupport;namespaceSeleniumDocs.Browsers{ [TestClassCustom] [EnabledOnOs("WINDOWS")]publicclassInternetExplorerTest{privateInternetExplorerDriver_driver;privatestring_logLocation;privatestring_tempPath; [TestCleanup]publicvoidCleanup(){if(_logLocation!=null&&File.Exists(_logLocation)){File.Delete(_logLocation);}if(_tempPath!=null&&File.Exists(_tempPath)){File.Delete(_tempPath);}_driver.Quit();} [TestMethod]publicvoidBasicOptionsWin10(){varoptions=newInternetExplorerOptions();options.AttachToEdgeChrome=true;options.EdgeExecutablePath=GetEdgeLocation();_driver=newInternetExplorerDriver(options);} [TestMethod]publicvoidBasicOptionsWin11(){varoptions=newInternetExplorerOptions();_driver=newInternetExplorerDriver(options);} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToFile(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Console.WriteLine("Lines: {0}",lines);Assert.IsTrue(lines.Contains("Started InternetExplorerDriver server"));} [TestMethod] [Ignore("Not implemented")]publicvoidLogsToConsole(){varstringWriter=newStringWriter();varoriginalOutput=Console.Out;Console.SetOut(stringWriter);varservice=InternetExplorerDriverService.CreateDefaultService();//service.LogToConsole = true;_driver=newInternetExplorerDriver(service);Assert.IsTrue(stringWriter.ToString().Contains("geckodriver INFO Listening on"));Console.SetOut(originalOutput);stringWriter.Dispose();} [TestMethod]publicvoidLogsLevel(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LogFile=GetLogLocation();service.LoggingLevel=InternetExplorerDriverLogLevel.Warn;_driver=newInternetExplorerDriver(service);_driver.Quit();// Close the Service log file before readingvarlines=File.ReadLines(GetLogLocation());Assert.IsNotNull(lines.FirstOrDefault(line=>line.Contains("Invalid capability setting: timeouts is type null")));} [TestMethod]publicvoidSupportingFilesLocation(){varservice=InternetExplorerDriverService.CreateDefaultService();service.LibraryExtractionPath=GetTempDirectory();_driver=newInternetExplorerDriver(service);Assert.IsTrue(File.Exists(GetTempDirectory()+"/IEDriver.tmp"));}privatestringGetLogLocation(){if(_logLocation==null||!File.Exists(_logLocation)){_logLocation=Path.GetTempFileName();}return_logLocation;}privatestringGetTempDirectory(){if(_tempPath==null||!File.Exists(_tempPath)){_tempPath=Path.GetTempPath();}return_tempPath;}privatestringGetEdgeLocation(){returnEnvironment.GetEnvironmentVariable("EDGE_BIN");}}}
# frozen_string_literal: truerequire'spec_helper'RSpec.describe'Internet Explorer',exclusive:{platform::windows}dodescribe'Options'dolet(:edge_location){ENV.fetch('EDGE_BIN',nil)}let(:url){'https://www.selenium.dev/selenium/web/'}beforedo@options=Selenium::WebDriver::IE::Options.new@options.attach_to_edge_chrome=true@options.edge_executable_path=edge_locationendit'basic options Win10'dooptions=Selenium::WebDriver::IE::Options.newoptions.attach_to_edge_chrome=trueoptions.edge_executable_path=edge_location@driver=Selenium::WebDriver.for:ie,options:optionsendit'basic options Win11'dooptions=Selenium::WebDriver::Options.ie@driver=Selenium::WebDriver.for:ie,options:optionsendit'sets the file upload dialog timeout'do@options.file_upload_dialog_timeout=2000driver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ensures a clean session'do@options.ensure_clean_session=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the zoom setting'do@options.ignore_zoom_level=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'ignores the protected mode settings'do@options.ignore_protected_mode_settings=truedriver=Selenium::WebDriver.for(:ie,options:@options)driver.quitendit'adds the silent option',skip:'This capability will be added on the release 4.22.0'do@options.silent=trueexpect(@options.silent).tobe_truthyendit'sets the command line options'do@options.add_argument('-k')Selenium::WebDriver.for(:ie,options:@options)endit'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=trueSelenium::WebDriver.for(:ie,options:@options)expect(@options.instance_variable_get(:@options)['force_create_process_api']).toeq({force_create_process_api:true})endenddescribe'Service'dolet(:file_name){Tempfile.new('iedriver').path}let(:root_directory){Dir.mktmpdir}afterdoFileUtils.rm_f(file_name)FileUtils.remove_entryroot_directoryendit'logs to file'doservice=Selenium::WebDriver::Service.ieservice.log=file_name@driver=Selenium::WebDriver.for:ie,service:serviceexpect(File.readlines(file_name).first).toinclude('Started InternetExplorerDriver server')endit'logs to console'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutexpect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Started InternetExplorerDriver server/).to_stdout_from_any_processendit'sets log level'doservice=Selenium::WebDriver::Service.ieservice.log=$stdoutservice.args<<'-log-level=WARN'expect{@driver=Selenium::WebDriver.for:ie,service:service}.tooutput(/Invalid capability setting: timeouts is type null/).to_stdout_from_any_processendit'sets location for supporting files'doservice=Selenium::WebDriver::Service.ieservice.args<<"–extract-path=#{root_directory}"@driver=Selenium::WebDriver.for:ie,service:serviceendendend