您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Selenium報錯以及各解決方法
作者:auto杰森 發(fā)布時間:[ 2017/2/22 10:24:24 ] 推薦標簽:功能測試 selenium

  1.driver.findElement(By.name("wd")).sendKeys("selenium");
  報錯:The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
  原因:舊版本的Java不理解非隨機變量參數(shù)
  解決方法:在工程上點擊右鍵選擇Properties -> Java Compiler,選擇1.7版本
  2.selenium在IE11上報錯“找不到元素”
  IE11不支持Selenium 2.0,在什么情況下不支持呢?比如:通過WebDriver獲取頁面上的元素時,經(jīng)常會捕獲到這樣的異常:
  OpenQA.Selenium.NoSuchWindowException: Unable to find element on closed window
  at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:ProjectswebdriverdotnetsrcwebdriverRemoteRemoteWebDriver.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_MACHINESOFTWAREMicrosoftInternet ExplorerMainFeatureControlFEATURE_BFCACHE.(32bit Windows看這里。)
  For 64-bit Windows installations, the key is HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoftInternet ExplorerMainFeatureControlFEATURE_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_MACHINESOFTWAREWow6432NodeMicrosoftInternet ExplorerMainFeatureControlFEATURE_BFCACHE
  如果FeatureControl下沒有FEATURE_BFCACHE,以FEATURE_BFCACHE為名new一個key!并在其下創(chuàng)建一個DWORD,取名為:iexplore.exe,value為0。

  修改完你的注冊表后,重啟你的計算機。之后以管理員權(quán)限運行Visual Studio(或者eclipse),打開你的項目,運行,你會發(fā)現(xiàn),問題解決了。(注意:如果不使用管理員身份運行將仍然報錯。)

軟件測試工具 | 聯(lián)系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd