多测师是一家拥有先进的教学理念,强大的师资团队,业内好评甚多的接口自动化测试培训机构!

17727591462

联系电话

您现在所在位置:接口自动化测试培训 > 新闻资讯

IE11不支持Selenium 2.0的解决方法-自动化测试

更新时间:2022-04-26 09:24:45 作者:多测师 浏览:301

  问题概述(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

IE11不支持Selenium 2.0的解决方法-自动化测试

  上面这段异常的重点在于:

  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,打开你的项目,运行,你会发现,问题解决了。

  以上内容为大家介绍了自动化测试中的IE11不支持Selenium 2.0的解决方法,本文由多测师亲自撰写,希望对大家有所帮助。了解更多自动化测试相关知识:https://www.aichudan.com/xwzx/

联系电话

17727591462

返回顶部