Internet Explorer自动化不适用于IE11 [英] Internet Explorer automation not working with IE11

查看:640
本文介绍了Internet Explorer自动化不适用于IE11的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码可以通过VBA中的Internet Explorer自动化从多个网站检索数据。我的代码在IE8中没有问题,但是在IE11中,在调用Internet Explorer对象的Navigate方法之后,Document和LocationURL没有更新;他们仍然参考以前显示的网站。以下是重现问题的一些代码:

I have some code that retrieves data from multiple websites via Internet Explorer automation in VBA. My code worked without problems with IE8, but in IE11, after the Navigate method of the Internet Explorer object is called, the Document and LocationURL are not updated; they still refer to the previously displayed website. Here's some code to reproduce the problem:

Sub Test()
    Debug.Print "start"
    Dim ie
    Set ie = CreateObject("InternetExplorer.Application")
    ie.Visible = True
    ie.Navigate "http://en.wikipedia.org/wiki/Visual_Basic"
    wait ie
    Debug.Print "Current URL: " & ie.LocationURL
    ie.Navigate "http://en.wikipedia.org/wiki/Microsoft_Office"
    wait ie
    Debug.Print "Current URL: " & ie.LocationURL
    Set ie = Nothing
End Sub

Sub Wait(ie As Variant)
    Do While ie.Busy
        Application.wait DateAdd("s", 1, Now)
    Loop
End Sub

当a在具有IE8的机器上运行上面的Test子,它打印两个不同的URL,这是预期的行为。但是,当我在使用IE11的计算机上运行相同的代码时,它会打印第一个URL两次。知道可能出现什么问题吗?

When a run the above Test sub on a machine with IE8, it prints two different URLs, which is the expected behavior. However, when I run the same code on a machine with IE11, it prints the first URL twice. Any idea what might be wrong?

更新:我找不到解决方案,所以我选择了打开新IE的解决方法每个URL的窗口。

Update: I couldn't find a solution, so I went for the workaround of opening a new IE window for each URL.

推荐答案

我不熟悉你正在使用的VBA IE自动化,但听起来你似乎是在IE11上遇到与Selenium WebDriver相同的问题。

I am not familiar with the VBA IE automation that you are using, however it sounds like you are hitting the same issue as Selenium WebDriver on IE11.

您可能需要遵循Selenium Wiki中提供的相同步骤。

You may need to follow the same steps provided by the in the Selenium Wiki.


仅对于IE 11,您需要在目标
计算机上设置一个注册表项,以便驱动程序可以维护连接到它创建的Internet Explorer实例
。对于32位Windows安装,您必须在注册表编辑器中检查的
键是
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Internet *
Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。对于64位Windows
安装,密钥为
HKEY_LOCAL_MACHINE\SOFTWARE \ Wow6432Node\Microsoft\Internet
Explorer \ Main \ FeatureControl \ FEATURE_BFCACHE。请注意,
FEATURE_BFCACHE子项可能存在也可能不存在,如果不存在,则应创建
。重要说明:在此键内,创建名为iexplore.exe的
DWORD值,值为0.

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. 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. For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE. Please note that the FEATURE_BFCACHE subkey may or may not be present, and should be created if it is not present. Important: Inside this key, create a DWORD value named iexplore.exe with the value of 0.

http://code.google.com/p/selenium/wiki/InternetExplorerDriver

希望能解决您的问题!

这篇关于Internet Explorer自动化不适用于IE11的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆