简体   繁体   English

无法使用带有 Java 的 Selenium WebDriver 打开 IE11 驱动程序实例

[英]Unable to open IE11 driver instance using Selenium WebDriver with Java

    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.线程“main”org.openqa.selenium.remote.SessionNotFoundException 中的异常:启动 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 (警告:服务器没有提供任何堆栈跟踪信息)命令持续时间或超时:1.33 秒

Can anyone suggest to resolve this issue?任何人都可以建议解决这个问题吗?

You cannot open IE browser instance if Protected Mode settings are not the same for all zones OR if the browser is zoomed.如果所有区域的保护模式设置不同,或者浏览器被缩放,则无法打开 IE 浏览器实例。

  1. To resolve this, Open IE Browser and go to Internet Options windows.要解决此问题,请打开 IE 浏览器并转到Internet 选项窗口。
  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.单击“安全”选项卡并确保“ Internet ”、“本地 Intranet ”、“受信任的站点”和“受限制的站点”的所有选项都选中或取消选中“启用保护模式”。
  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.注意:如果您无权更改 IE 设置,请联系您的 IT 管理员以完成所需的更改。

  • 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.保护模式是 Internet Explorer (IE)安全性向前迈出的重要一步,它通过运行具有极大限制权限的 IE 进程来帮助保护用户免受攻击。
  • Protected Mode settings, like almost all other settings of IE, are stored in the Windows registry and are checked when the browser is instantiated.保护模式设置与 IE 的几乎所有其他设置一样,都存储在 Windows 注册表中,并在浏览器实例化时进行检查。
  • 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.司机需要一个解决方法谁也不能设置这些IE的设置,因为他们的机器被过度锁定,所以引入capabiltity fetaure人。
  • 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 .为了帮助警告人们这个潜在的问题,该功能被赋予了一些听起来很吓人的名字,比如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.要求您的 IT 支持人员进行更改,如果仍在使用该功能,您将面临代码稳定性的风险。

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这将引入一些片状

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM