量角器“错误 - 无法启动WebDriver会话”

时间:2015-01-18 14:01:21

标签: angularjs selenium jasmine protractor

我对我的单页应用程序进行了一些测试。 测试是在量角器中。

他们之前在构建过程中运行过,但是现在我把所有这些都移到了一个分支上,一些东西被打破了,当我运行测试时我得到了:

Running "protractor:normal" (protractor) task
Starting selenium standalone server...
[launcher] Running 1 instances of WebDriver
Selenium standalone server started at http://172.31.9.226:23730/wd/hub
ERROR - Unable to start a WebDriver session.

c:\projects\blog-manager\node_modules\protractor\node_modules\selenium-    webdriver\lib\atoms\error.js:113
var template = new Error(this.message);
             ^
Warning: Protractor test(s) failed. Exit code: 1 Use --force to continue.

Aborted due to warnings.

Process finished with exit code 6

conf文件如下:

'use strict';

module.exports.config = {
    allScriptsTimeout: 60000,

    baseUrl: 'http://localhost:9000/',

    specs: [
            process.cwd() + '/test/spec/e2e/**/*.js'//,
           // process.cwd() + '/test/e2e/spec/**/*.js'
    ],

    framework: 'jasmine',

    capabilities: {
        browserName: 'chrome',
        "chromeOptions": {
            binary: "C:/Program Files      (x86)/Google/Chrome/Application/chrome.exe",
            args: [],
           extensions: [],
        }
    },

    onPrepare: function () {
        // Disable animations so e2e tests run more quickly
        var disableNgAnimate = function () {
            angular.module('disableNgAnimate', []).run(function ($animate) {
                $animate.enabled(false);
            });
        };

        browser.addMockModule('disableNgAnimate', disableNgAnimate);

        // Store the name of the browser that's currently being used.
        browser.getCapabilities().then(function (caps) {
            browser.params.browser = caps.get('browserName');
        });
    },

    jasmineNodeOpts: {
        defaultTimeoutInterval: 300000
    }
};

如何解决这个问题的任何建议都将非常感激。

谢谢!

1 个答案:

答案 0 :(得分:1)

根据alecxe的回答,它是chrome二进制问题,可以通过在chromedriver预期为或指定二进制设置的可执行路径的同一位置安装chrome来解决。

capabilities: {
    "browserName": "chrome",
    "chromeOptions": {
        binary: "D:/Program Files/Chrome/chrome.exe",
        args: [],
        extensions: [],
    }
},

查看他的回答here

即使您正确设置了可执行文件路径,但对我来说似乎没什么用的二进制文件:"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",

这是对的吗?

或者,我会尝试this