Unable to open IE11 driver instance using Selenium WebDriver with Java

六眼飞鱼酱① 提交于 2019-12-01 05:47:26

问题


    System.setProperty("webdriver.ie.driver","C:\\Users\\IEDriverServer_Win32_2.45.0\\IEDriverServer.exe");

    WebDriver driver = new InternetExplorerDriver();

    driver.get("http://xxx");

Shows error while executing above code:

Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 1.33 seconds

Can anyone suggest to resolve this issue?


回答1:


If u are behind proxy with no access provision to change the protected mode settings then use this capabilities

DesiredCapabilities cap = DesiredCapabilities.internetExplorer();
        cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);

this will introduce some flakiness




回答2:


You cannot open IE browser instance if Protected Mode settings are not the same for all zones OR if the browser is zoomed.

  1. To resolve this, Open IE Browser and go to Internet Options windows.
  2. Click on Security tab and make sure 'Internet','Local Intranet','Trusted sites' and 'Restricted sites' have 'Enable Protected Mode' either checked or unchecked for all options.
  3. Apply and save the settings and re-run the test code. It should work.

Below workaround is provided which will help you to temporarily solve the problem.

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();

caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);

WebDriver driver = new InternetExplorerDriver(caps); 

Note : If you don't have permission to change IE settings,Request you to contact your IT administrator to get the required changes done.

  • Protected Mode is an important step forward in security for Internet Explorer (IE), it helps protect users from attack by running an IE process with greatly restricted privileges.
  • Protected Mode settings, like almost all other settings of IE, are stored in the Windows registry and are checked when the browser is instantiated.
  • The driver needed a workaround for people who couldn't set those IE settings because their machine was overly locked down and so capabiltity fetaure was introduced.
  • It simply bypasses the registry check. Using the capability doesn't solve the underlying problem though.
  • Unexpected hangs, element location not working, and clicks not being propagated, could result.
  • To help warn people of this potential problem, the capability was given big scary-sounding names like INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS.
  • Ask your IT support to make the changes and if still using the capability you are risking the stability of your code.


来源:https://stackoverflow.com/questions/29642940/unable-to-open-ie11-driver-instance-using-selenium-webdriver-with-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!