无法使用selenium-webdriver启动或连接到Chrome

时间:2013-05-20 06:04:51

标签: javascript webdriver selenium-webdriver selenium-chromedriver

我正在创建webdriver,如下所示:

var driver = require("selenium-webdriver");
driver = new webdriver.Builder().
    usingServer(server.address()).
    withCapabilities({'browserName': 'chrome'}).
    build();

it('should append query to title', function() {
        driver.get('http://www.google.com');
        driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');
        driver.findElement(webdriver.By.name('btnG')).click();
        driver.wait(function() {
            return driver.getTitle().then(function(title) {
                return 'webdriver - Google Search' === title;
            });
        }, 1000);
    });

这在firefox上工作正常。使用chrome,打开chrome实例后会给我以下异常:有谁能告诉我如何解决这个问题?此外,Chrome版本26.0.1410.65是最新的。

我的计算机上安装了最新版本的chromedriver

 UnknownError: Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28.32 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.7.3', java.version: '1.6.0_31'
Driver info: org.openqa.selenium.chrome.ChromeDriver

2 个答案:

答案 0 :(得分:0)

好像你没有镀铬驱动程序bin设置。请参阅我之前的回答here

System.setProperty("webdriver.chrome.driver", "\pathto\my\chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");

答案 1 :(得分:0)

Chromedriver版本应该是最新版本。有一次,我更新了chromedriver,问题得到解决。我使用自制软件在Mac上更新了chromedriver,如下所示: brew更新; brew升级chromedriver