最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Protractor gives "Unable to start a WebDriver session" error - Stack Overflow

programmeradmin0浏览0评论

I already have started a server with webdriver-manager start, but I get this error when I try to run protractor:

Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.

C:\...\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
  var template = new Error(this.message);
                 ^
UnknownError: unknown error: cannot find Chrome binary

My config file looks like this:

exports.config = {
    specs: [
        'test/*.js'
    ],

    capabilities: {
        'browserName': 'chrome'
    },
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub'

};

I have also tried pointing to the binary in the capabilities object as well as adding chromeDriver and seleniumServerJar keys to no avail. Any ideas?

I already have started a server with webdriver-manager start, but I get this error when I try to run protractor:

Using the selenium server at http://127.0.0.1:4444/wd/hub
[launcher] Running 1 instances of WebDriver
ERROR - Unable to start a WebDriver session.

C:\...\npm\node_modules\protractor\node_modules\selenium-webdriver\lib\atoms\error.js:113
  var template = new Error(this.message);
                 ^
UnknownError: unknown error: cannot find Chrome binary

My config file looks like this:

exports.config = {
    specs: [
        'test/*.js'
    ],

    capabilities: {
        'browserName': 'chrome'
    },
    seleniumAddress: 'http://127.0.0.1:4444/wd/hub'

};

I have also tried pointing to the binary in the capabilities object as well as adding chromeDriver and seleniumServerJar keys to no avail. Any ideas?

Share Improve this question edited Apr 3, 2015 at 20:27 alecxe 474k127 gold badges1.1k silver badges1.2k bronze badges asked Dec 15, 2014 at 21:44 cgsdcgsd 1,3232 gold badges14 silver badges26 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 12

According to the relevant github issue, the problem is that chromedriver cannot find chrome browser executeable - on different operating systems it searches for it in different places.

You need to either have chrome installed where chromedriver expects it to be, or specify the path to the chrome executeable in the binary setting:

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

I generated code using JHipster and had similar error where e2e was not working. I provided binary path. But upon npm run e2e the browser opened and displayed data; in the address bar.

I shuffled and provided the binary at the end of chromeOptions after the args and it worked.

capabilities: {
        browserName: 'chrome',
        chromeOptions: {
            args: process.env.JHI_E2E_HEADLESS
                ? [ "--headless", "--disable-gpu", "--window-size=800,600" ]
                : [ "--disable-gpu", "--window-size=800,600" ],
            binary: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
        }
    }

Note: I also had to update the chrome version when an unsupported webdriver version error occurred.

发布评论

评论列表(0)

  1. 暂无评论