IE11不支持Selenium 2.0的解决方法
来源:互联网 发布:win7重装网络协议 编辑:程序博客网 时间:2024/05/20 11:27
题前话(Pre-words)
希望使用Selenium 2.0的人看到这篇文章能够收藏此文,以后遇到该问题,再也不用花费多余的时间进行research了!本文就是对网上所有千奇百怪各种各样的search结果所做的最好总结。
问题概述(Question)
IE11不支持Selenium 2.0,在什么情况下不支持呢?比如:获取通过WebDriver获取页面上的元素时,你经常会捕获到这样的异常:
OpenQA.Selenium.NoSuchWindowException: Unable to find element on closed window
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1139
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 923
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value) in c:\Projects\webdriver\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 954
at SharePoint_Automation.mainForm.waitUntilPageLoaded(IWebDriver iw, String eleID) in C:\Users\Administrator\documents\visual studio 2015\Projects\SharePoint Automation\SharePoint Automation\Form1.cs:line 116
上面这段异常的重点在于:
OpenQA.Selenium.NoSuchWindowException: Unable to find element on closed window
解决方案(Solution)
经过不屑的努力,最终让我找到了这一问题的解决方案如下(蓝色字体为针对64bit计算机的最终解决手段):
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. (32bit Windows看这里。)
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.(64bit Windows看这里。)
翻译过来的意思即,修改你的注册表(Run->regedit->Enter),路径如下:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE
如果FeatureControl下没有FEATURE_BFCACHE,就以FEATURE_BFCACHE为名new一个key!并在其下创建一个DWORD,取名为:iexplore.exe,value为0。
修改完你的注册表后,重启你的计算机。之后以管理员权限运行Visual Studio,打开你的项目,运行,你会发现,问题解决了。
Congratulations!这几个小时没有白费,终于让我找到了解决方案!网上千奇百怪的说法很多,但是没有一个好使的!
希望看到这篇文章的人能够收藏此文,以后遇到了这个问题,再也不用花费多余的时间进行research了!
感谢以下两篇文章:
Selenium - NoSuchWindowException in IE 11
InternetExplorerDriver
另:
若想正常使用WebDriver,请确保你的浏览器选项中security中各个zone的Protected Mode都是勾选着/非勾选着的,一定要统一才行!否则WebDriver将无法打开浏览器,会有如下异常:
System.InvalidOperationException: 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. (NoSuchDriver)
- IE11不支持Selenium 2.0的解决方法
- IE11不支持Selenium 2.0的解决方法
- IE11不支持Selenium 2.0 的解决办法
- IE11 不支持 document.selection
- 解决loadrunner12不能破解、loadrunner11不支持IE11录制的问题
- IE10、IE11出现“_doPostBack未定义”的解决方法
- IE11 经常崩溃的一个解决方法
- 让IE6 ~IE11支持Bootstrap的解决方法
- HP QC IE11不支持( win7 64位 无法安装)解决方法
- HP QC IE11不支持( win7 64位 无法安装)解决方法
- selenium+webdriver:不支持导出iframe的处理
- IE11不支持HTML5中的template
- IIS不支持中文名的解决方法
- mysql不支持中文的解决方法
- aptana不支持gbk的解决方法
- eWebEditor不支持IE8的解决方法
- IIS不支持PHP的解决方法
- FireFox不支持InnerText的解决方法
- 博客开篇
- ubuntu14.04安装cuda8.0
- http://www.ruanyifeng.com/blog
- Label Encoding & One-Hot Encoding
- yarn-5
- IE11不支持Selenium 2.0的解决方法
- 图像清晰度评价
- 静态链接的编译过程和链接过程
- jquery 实现轮播图
- BZOJ 3289 Mato的文件管理
- 南阳理工OJ---ASCII码排序
- POJ 1276 Cash Machine(多重背包)
- Java 泛型详解
- 使用阿里云实现简单的直播