1
我正在Selenium和Chrome驅動程序的幫助下運行我的Wicket項目的JUnit測試。在使用ChromeDriver設置networkConnection時出現「必須啓用網絡連接」錯誤
我們的網站支持HTML5離線模式使用清單和所有,我們也想測試。
我們使用ChromeDriver像:
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("binary", binarylocation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
capabilities.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true);
driver = new ChromeDriver(capabilities);
但unfourtnetly,還有在我的測試中嘗試這個時候會出現錯誤:
((NetworkConnection) chromeDriver).setNetworkConnection(ConnectionType.NONE);
的錯誤是:
org.openqa.selenium.WebDriverException: unknown error: network connection must be enabled
(Session info: chrome=57.0.2987.98)
(Driver info: chromedriver=2.29.461591 (62ebf098771772160f391d75e589dc567915b233),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 4 milliseconds
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'xxx', ip: 'xx.xx.xx.xx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.29.461591 (62ebf098771772160f391d75e589dc567915b233), userDataDir=C:\Users\xxx\AppData\Local\Temp\scoped_dir164_11339}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=57.0.2987.98, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: c344d7f922bc0973d46959e17103672c
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)
at org.openqa.selenium.remote.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.mobile.RemoteNetworkConnection.setNetworkConnection(RemoteNetworkConnection.java:46)
at org.openqa.selenium.chrome.ChromeDriver.setNetworkConnection(ChromeDriver.java:230)
關於此問題:https://bugs.chromium.org/p/chromedriver/issues/detail?id=984此功能應該是可能的,但不知何故,它不是?
有人能給我一個提示嗎?