【问题标题】:error: cannot find Chrome binary - Selenium OSX java Eclipse错误:找不到 Chrome 二进制文件 - Selenium OSX java Eclipse
【发布时间】:2017-04-09 05:50:57
【问题描述】:

我正在尝试使用 Selenium 启动 Chrome。我能够将相同的代码(稍作改动)应用到 Firefox,但由于某种原因 Chrome 无法正常工作。
它说它找不到 Chrome 二进制文件,但我已将 chromedriver 正确链接到其文件源。

反馈任何人?

代码:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class scociatest1 {
    public static void main(String[] args) {
        System.setProperty("webdriver.chrome.driver", "/Users/theone/Downloads/chromedriver-2");

        // Create a new instance of the Chrome driver
        WebDriver driver = new ChromeDriver();

        //Launch the Scocia Demo Website
        driver.get("https://apps.scotiabank.com/LEAP_Prototype/desktop/html/Chile_index.html#");

        // Print a Log In message to the screen
        System.out.println("Successfully opened the website");
    }
}

错误详情:

在端口 33806 上启动 ChromeDriver 2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4) 只允许本地连接。 2016 年 11 月 24 日下午 4:14:02 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:尝试双语会话,假设 Postel 定律在远程端成立 2016 年 11 月 24 日下午 4:14:03 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:OSS 线程“主”org.openqa.selenium.NoSuchSessionException 中的异常:没有这样的会话 (驱动程序信息:chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.11.6 x86_64)(警告:服务器未提供任何堆栈跟踪信息) 命令持续时间或超时:15 毫秒 构建信息:版本:'未知',修订:'1969d75',时间:'2016-10-18 09:43:45 -0700' 系统信息:主机:'Thes-MacBook-Air.local',ip:'10.0.9.17',os.name:'Mac OS X',os.arch:'x86_64',os.version:'10.11.6' , java.version: '1.8.0_112' 驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能 [{message=unknown error: 找不到 Chrome 二进制文件 (驱动程序信息:chromedriver=2.21.371459(36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),平台=Mac OS X 10.11.6 x86_64),平台=ANY}] 会话 ID:ede6a5a0ba4b5c7b2734be4418af439e 在 sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在 java.lang.reflect.Constructor.newInstance(Constructor.java:423) 在 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216) 在 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635) 在 org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322) 在 com.scocia.test.scociatest1.main(scociatest1.java:16)

【问题讨论】:

  • 驱动程序似乎连接得很好,因为它是报告错误的驱动程序 - 它描述的问题是它无法找到 Chrome 二进制文件 - 就像在浏览器本身一样。也许 Chrome 没有安装在默认位置? github.com/SeleniumHQ/selenium/wiki/ChromeDriver

标签: java macos selenium binary selenium-chromedriver


【解决方案1】:

您似乎是在一台 Windows 机器上运行您的测试。那么你的chromedriver应该是一个exe文件——>“/Users/theone/Downloads/chromedriver-2.exe”。之后如果还是不行,可以用绝对路径检查一下。

【讨论】:

  • 一个明确提到平台是 Mac OS/X 的堆栈跟踪和一个说它是 OSX 的标签究竟是如何让你说它在 Windows 机器上运行的?
  • 我的错,我过于关注与我之前遇到的问题的相似性。
猜你喜欢
  • 1970-01-01
  • 2016-09-19
  • 2012-07-15
  • 2021-04-02
  • 1970-01-01
  • 2011-12-21
  • 2018-02-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多