简体   繁体   English

无法导航到 http://10.22.32.185 这通常意味着调用 COM 方法 IWebBrowser2::Navigate2() 在 Win10 上使用 IE 11 和 ZC49DFB55F06BB5707

[英]Failed to navigate to http://10.22.32.185 This usually means that a call to the COM method IWebBrowser2::Navigate2() using IE 11 on Win10 and Selenium

I have problem with start webdriver IE 11 in Selenium, Windows 10 version 20H2.我在 Selenium、Windows 10 版本 20H2 中启动 webdriver IE 11 时遇到问题。

[ERROR] Tests run: 23, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 820.596 s <<< FAILURE! - in TestSuite
[ERROR] test.TestTrunkIE.firstTestIE  Time elapsed: 0.07 s  <<< FAILURE!
org.openqa.selenium.WebDriverException: 
Failed to navigate to http://10.22.32.185:8090/login. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed. The error returned is: Received error: 0x800700aa ['Żądane zasoby są w użyciu.']
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'APS00080705-MB', ip: '10.58.97.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_251'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities {acceptInsecureCerts: false, browserName: internet explorer, browserVersion: 11, javascriptEnabled: true, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), se:ieOptions: {browserAttachTimeout: 0, elementScrollBehavior: 0, enablePersistentHover: false, ie.browserCommandLineSwitches: , ie.edgechromium: false, ie.edgepath: , ie.ensureCleanSession: false, ie.fileUploadDialogTimeout: 3000, ie.forceCreateProcessApi: false, ignoreProtectedModeSettings: true, ignoreZoomSetting: true, initialBrowserUrl: http://localhost:48363/, nativeEvents: false, requireWindowFocus: false}, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: accept}
Session ID: 02ba92b2-7827-413c-9b02-16d3156abd23
    at test.TestTrunkIE.firstTestIE(TestTrunkIE.java:51)

'The requested resource is in use.' 

It's my code:这是我的代码:

    @BeforeTest
    public void setUp() throws Exception {
        System.setProperty("webdriver.ie.driver", "lib\\IE\\IEDriverServer.exe");
        DesiredCapabilities caps = new DesiredCapabilities();
        caps.setCapability("nativeEvents", false);
        caps.setCapability("unexpectedAlertBehaviour", "accept");
        caps.setCapability("ignoreProtectedModeSettings", true);
        caps.setCapability("disable-popup-blocking", true);
        caps.setCapability("enablePersistentHover", true);
        caps.setCapability("ignoreZoomSetting", true);
        caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
        caps.setCapability("os", "Windows");
        caps.setCapability("os_version", "10");
        caps.setCapability("browser", "IE");
        caps.setCapability("browser_version", "11.0");
        caps.setCapability("resolution", "1920x1080");
        caps.setCapability("browserstack.local", true);
        caps.setCapability("browserstack.debug", true);
        caps.setCapability("browserstack.networkLogs", true);
        caps.setCapability("browserstack.selenium_version", "3.141.59");
        caps.setCapability("INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS", true);
        caps.setCapability("setJavascriptEnabled", true);
        steps = new WebDriverSteps(new InternetExplorerDriver(caps));
    }
'''
In Internet Exprorer I disable checkbox Enable Protected Mode ....  

'''
[ERROR] Failures: 
[ERROR]   TestTrunkIE.firstTestIE:51 » WebDriver Failed to navigate to http://10.22.32.1...
[ERROR]   TestTrunkIE.firstTestIE46:62 » WebDriver Failed to navigate to http://10.22.32...
[ERROR]   TestTrunkIE.firstTestIE46Krus:74 » WebDriver Failed to navigate to http://10.2...
[INFO] 

This error message...此错误消息...

org.openqa.selenium.WebDriverException: Failed to navigate to http://10.22.32.185:8090/login. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed.

...implies that the IEDriverServer was unable to initiate/spawn a new Browsing Context ie Internet Explorer Browser session as a COM object. ...暗示 IEDriverServer 无法启动/产生新的浏览上下文,即Internet Explorer 浏览器session 作为 COM object。


Protected Mode settings for Internet Explorer Internet Explorer 的保护模式设置

JimEvans in his article mentioned, while automating through : JimEvans在他的文章中提到,同时通过自动化器:

A browser session was represented by a single instance of the iexplore.exe executable.浏览器 session 由 iexplore.exe 可执行文件的单个实例表示。 A framework for driving IE could instantiate the browser as a COM object using CoCreateInstance() , or could easily get the COM interfaces to a running instance by using the presence of ActiveAccessibility and sending a WM_HTML_GETOBJECT message to the appropriate IE window handle. A framework for driving IE could instantiate the browser as a COM object using CoCreateInstance() , or could easily get the COM interfaces to a running instance by using the presence of ActiveAccessibility and sending a WM_HTML_GETOBJECT message to the appropriate IE window handle. Once the framework had a pointer to the COM interfaces, you could be sure that they'd be valid for the lifetime of the browser.一旦框架有一个指向 COM 接口的指针,您就可以确定它们在浏览器的整个生命周期内都是有效的。 It also meant you could easily attach to the events fired by the browser through the DWebBrowserEvents2 COM interface.Then along came the combination of IE 7 and Windows Vista.这也意味着您可以通过DWebBrowserEvents2 COM 接口轻松附加到浏览器触发的事件。然后是 IE 7 和 Windows Vista 的组合。 In and effort to reduce the attack surface presented by malicious web sites, IE 7 introduced something called Protected Mode , which leveraged Mandatory Integrity Control in Windows Vista to prevent actions initiated IE, usually initiated by JavaScript, from being able to access the operating system the way it could in prior releases. In and effort to reduce the attack surface presented by malicious web sites, IE 7 introduced something called Protected Mode , which leveraged Mandatory Integrity Control in Windows Vista to prevent actions initiated IE, usually initiated by JavaScript, from being able to access the operating system the在以前的版本中可以这样。 While this was generally a welcome development for most users of IE, it created all manner of problems for automating IE.虽然对于大多数 IE 用户来说,这通常是一个受欢迎的发展,但它为 IE 自动化带来了各种各样的问题。 When you cross into or out of Protected Mode by, say, navigating from an internal intranet website to one on the internet, IE has to create a new process, because it can't change the Mandatory Integrity Control level of the existing process.当您通过例如从内部 Intranet 网站导航到 Internet 上的网站进入或退出保护模式时,IE 必须创建一个新进程,因为它无法更改现有进程的强制完整性控制级别。 Moreover, in IE versions after 7, it's not always obvious that a Protected Mode boundary has been crossed, since IE tries to present a better user experience by seamlessly merging the browser window of the new process with the already opened browser window.此外,在 IE 7 之后的版本中,跨越保护模式边界并不总是很明显,因为 IE 试图通过将新进程的浏览器 window 与已经打开的浏览器 window 无缝合并来呈现更好的用户体验。 This under-the-covers process switching also means that any references pointing to IE's COM objects before the Protected Mode boundary crossing are left pointing to objects that are no longer used by IE after the boundary crossing.这种隐蔽的进程切换还意味着在保护模式边界交叉之前指向 IE 的 COM 对象的任何引用都将指向在边界交叉之后 IE 不再使用的对象。


Further, the Required Configuration of Internet Explorer Driver clearly mentions:此外, Internet Explorer 驱动程序必需配置清楚地提到:

  • The IEDriverServer exectuable must be downloaded and placed in your PATH. IEDriverServer必须下载并放置在您的 PATH 中。
  • On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value.在 Windows Vista 或 Windows 7 上的 IE 7 或更高版本上,您必须将每个区域的保护模式设置设置为相同的值。 The value can be on or off, as long as it is the same for every zone.该值可以打开或关闭,只要每个区域都相同。 To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab.要设置保护模式设置,请从“工具”菜单中选择“Internet 选项...”,然后单击“安全”选项卡。 For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".对于每个区域,标签底部都会有一个标记为“启用保护模式”的复选框。

保护模式设置

  • Additionally, Enhanced Protected Mode must be disabled for IE 10 and higher.此外,必须为 IE 10 及更高版本禁用增强保护模式 This option is found in the Advanced tab of the Internet Options dialog.此选项位于 Internet 选项对话框的Advanced选项卡中。
  • The browser zoom level must be set to 100% so that the native mouse events can be set to the correct coordinates.浏览器缩放级别必须设置为100% ,以便可以将本机鼠标事件设置为正确的坐标。
  • For Windows 10, you also need to set Change the size of text, apps, and other items to 100% in display settings.对于 Windows 10,您还需要在显示设置中将文本、应用程序和其他项目的大小更改100%
  • For IE 11 only, you will need to set a registry entry on the target computer so that the driver can maintain a connection to the instance of Internet Explorer it creates.仅对于 IE 11,您需要在目标计算机上设置一个注册表项,以便驱动程序可以保持与它创建的 Internet Explorer 实例的连接。
  • For 32-bit Windows installations, the key you must examine in the registry editor is HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE .对于 32 位 Windows 安装,您必须在注册表编辑器中检查的项是HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
  • For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE .对于 64 位 Windows 安装,密钥是HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
  • Note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present.请注意, FEATURE_BFCACHE子项可能存在也可能不存在,如果不存在,则应创建它。 Inside this key, create a DWORD value named iexplore.exe with the value of 0`.在此键中,创建一个名为iexplore.exeDWORD值,其值为 0`。

Solution解决方案

First, you need to ensure that the Protected Mode settings for each zone to be the same value .首先,您需要确保每个区域的保护模式设置为相同的值 Additionally you also need to ensure the Required Configuration for Internet Explorer Driver .此外,您还需要确保Internet Explorer 驱动程序必需配置


References参考

You can find a couple of relevant discussions in:您可以在以下位置找到一些相关的讨论:

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

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