因此,我正在 IE11 中自动化一个 Web 应用程序(为政府合同欢呼三声!),并且我按照 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 且值为 0 的 DWORD 值。
但它并没有真正解释为什么?如果没有添加此密钥会出现什么问题? “维护 IE 实例和网络驱动程序之间的连接”一词可能有很多不同的含义。
我们遇到的问题主要涉及 Selenium 方法,例如 .click() 不起作用或无法单击页面以供那些感兴趣的参考点使用。我们还遇到了一些奇怪的滚动问题,当元素刚刚离开屏幕时,它无法通过测试,这很奇怪,因为它应该读取 DOM,但我离题了。
你没看错。根据中的文档所需配置 https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration的部分Internet Explorer驱动程序 https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver其中明确提到:
For 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.
Note The FEATURE_BFCACHE
子项可能存在也可能不存在,如果不存在则应创建。重要提示:在此注册表项内,创建一个名为 iexplore.exe 且值为 0 的 DWORD 值。
一个简短的历史
根据@JimEvans 在讨论中的评论IE11 与 IEDriverServer 异常:无法获取浏览器 https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/6511:
On 16 December 2014, Microsoft released update KB3025390 via Windows Update https://support.microsoft.com/kb/3025390 as part of its normal "patch Tuesday" update cycle. For most users, this update is downloaded and installed without user interaction. This update breaks the IE driver when using it with IE11.
As part of this update, attempting to use the COM method IHTMLWindow2::execScript http://msdn.microsoft.com/en-us/library/ie/ms536420%28v=vs.85%29.aspx returns an "access denied" result. This renders the driver unable to execute JavaScript in the page bring browsed. However, given that large portions of driver functionality are implemented using JavaScript, this effectively renders the driver all but unusable with IE11.
There is no known workaround for this issue. At this time, the Microsoft IE driver implementation is still incomplete, lacking basic functionality required to make it usable, so it cannot be recommended. Uninstalling the update might restore IE driver functionality, but this is hardly ideal.
While the execScript method is marked as deprecated for IE11, the driver had heretofore been able to use that method successfully, and it was hoped that it would remain useful throughout the IE11 life cycle. We now know this not to be the case. Additionally, attempts to use the Microsoft-suggested replacement, eval http://msdn.microsoft.com/en-us/library/ie/bg182625(v=vs.85).aspx#legacyAPIs, have been fruitless thus far.
The issue is currently being tracked in the Selenium issue tracker https://code.google.com/p/selenium/issues/detail?id=8302.
在此讨论中@JimEvans 进一步添加了评论:
该注册表项禁用 IE 的一项名为 BFCache 的缓存功能,该功能会影响使用浏览器的向前和向后导航功能时缓存和加载页面的方式。启用后,驱动程序所依赖的 COM 对象(是的,驱动程序使用的完全相同的对象)mshtml
库)成为orphaned如果您向后或向前导航。还有其他方法可以提高驾驶员的“可靠性”click()
method.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)