Web应用测试项目的源码
?其中测试代码为:
?出现如下错误:
Starting ChromeDriver 2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91) on port 24602 Only local connections are allowed. 十一月 21, 2021 11:20:32 下午 org.openqa.selenium.remote.ProtocolHandshake createSession 信息: Detected dialect: OSS Exception in thread "main" org.openqa.selenium.NoSuchSessionException: no such session ? (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 14 milliseconds Build info: version: '3.3.0', revision: 'b526bd5', time: '2017-03-07 11:21:31 -0800' System info: host: 'CN-20210905WFZX', ip: '192.168.0.83', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_251' Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{message=unknown error: cannot find Chrome binary ? (Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64), platform=ANY}] Session ID: 6a1be3062154976f69a5400a53238a78 ?? ?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:216) ?? ?at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) ?? ?at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638) ?? ?at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325) ?? ?at moocTest.TestMain.main(TestMain.java:14) ?
实际上述原因是未安装Chrome浏览器。
为了使selenium安装成功,务必将chromeDriver的路径添加到path路径中,经过测试“webdriver.chrome.driver”环境变量可以不用设置。
?
|