1. 程式人生 > >Robot Framework IE11 Selenium2Library 找不到視窗 找不到物件 找不到元素 登錄檔

Robot Framework IE11 Selenium2Library 找不到視窗 找不到物件 找不到元素 登錄檔

轉載至:http://www.cnblogs.com/LanTianYou/p/4811236.html

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.exevalue0


修改完你的登錄檔後,重啟你的計算機。之後以管理員許可權執行Visual Studio(或者eclipse),開啟你的專案,執行,你會發現,問題解決了。(注意:如果不使用管理員身份執行將仍然報錯。)