Selenium 给出“未知错误:找不到 Chrome 二进制文件";在 Ubuntu 上运行 chrome 驱动程序时
我正在尝试在最新的 ubuntu 上使用 chrome 驱动程序运行 selenium [java] 测试.[16.04]
I am trying to run selenium [java] tests using chrome driver on Latest ubuntu.[16.04]
我收到以下错误/异常.作为一个实验,我用我的原生helloworldApp"替换了 ChromeDriver 二进制文件;我发现 selenium 正在执行我的二进制文件.
I am getting the following error/exception. As an experiment, I replaced ChromeDriver binary with my native "helloworldApp"; I found that selenium is executing my binary.
我相信端口 15306 上的打印Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320)"来自 Chrome 二进制文件.但是为什么 selenium 抱怨它无法获得二进制文件?
I believe the print "Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 15306" is coming from chrome binary. But why selenium complaining that its not able to get the binary?
在 Windows 上一切正常.
Everything works fine on Windows.
请指教.
[java] Starting ChromeDriver 2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320) on port 15306
[java] Only local connections are allowed.
[java] Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot find Chrome binary
[java] (Driver info: chromedriver=2.27.440175 (9bc1d90b8bfa4dd181fbbf769a5eb5e575574320),platform=Linux 4.8.0-46-generic x86_64) (WARNING: The server did not provide any stacktrace information)
[java] Command duration or timeout: 328 milliseconds
[java] Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
[java] System info: host: 'geo-VirtualBox', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-46-generic', java.version: '9-internal'
[java] Driver info: org.openqa.selenium.chrome.ChromeDriver
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(java.base@9-internal/Native Method)
[java] at sun.reflect.NativeConstructorAccessorImpl.newInstance(java.base@9-internal/NativeConstructorAccessorImpl.java:62)
[java] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(java.base@9-internal/DelegatingConstructorAccessorImpl.java:45)
[java] at java.lang.reflect.Constructor.newInstance(java.base@9-internal/Constructor.java:453)
[java] at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
[java] at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
[java] at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
[java] at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
[java] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
[java] at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
[java] at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
[java] at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:138)
我发现了问题.在我的 linux 系统上,未安装 Google Chrome 浏览器.
I found the problem. On my linux system, Google Chrome Browser was not installed.
我的印象是 ChromeDriver 二进制文件中有一个浏览器实现.现在我意识到这是错误的,ChromeDriver 二进制文件是一个调用 Google Chrome 的 selenium 包装器.
I was under the impression that ChromeDriver binary has got a browser implementation in it. Now I realized that's wrong , ChromeDriver binary is a selenium wrapper that calls Google Chrome.
我必须说异常消息selenium.WebDriverException:未知错误:找不到 Chrome 二进制文件" 令人困惑.如果它告诉Chrome 浏览器未安装"或类似的东西,事情会容易得多.
I must say that the exception message "selenium.WebDriverException: unknown error: cannot find Chrome binary" is confusing. If it was telling that "Chrome Browser is not installed" or something similar it would have been much easier.
谢谢乔治