Selenium报错以及各解决方法

发表于:2017-2-21 11:14

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:auto杰森    来源:51Testing软件测试网采编

  1.driver.findElement(By.name("wd")).sendKeys("selenium");
  报错:The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
  原因:旧版本的Java不理解非随机变量参数
  解决方法:在工程上点击右键选择Properties -> Java Compiler,选择1.7版本
  2.selenium在IE11上报错“找不到元素”
  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
  解决方法:
  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(或者eclipse),打开你的项目,运行,你会发现,问题解决了。(注意:如果不使用管理员身份运行将仍然报错。)
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号