1. 程式人生 > >Selenium+webDriver 啟動IE11 瀏覽器報錯“org.openqa.selenium.NoSuchWindowException”

Selenium+webDriver 啟動IE11 瀏覽器報錯“org.openqa.selenium.NoSuchWindowException”

Selenium2+webDriver 啟動IE11報錯

org.openqa.selenium.NoSuchWindowException: Unable to get browser (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 17 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'WIN-1IHOGI5MNTQ', ip: '10.0.6.42', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_60'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=
http://localhost:36188/
, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=true, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}] 解決方案: 1.修改登錄檔(Ctrl+R --> regedit--> Enter) 2.修改登錄檔路徑: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BFCACHE 如果FeatureControl下沒有FEATURE_BFCACHE,就以FEATURE_BFCACHE為名new一個key!並在其下建立一個DWORD,取名為:iexplore.exe,value為0。 特別注意:
若想正常使用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)