【问题标题】:Protractor gives "Unable to start a WebDriver session" error量角器给出“无法启动 WebDriver 会话”错误
【发布时间】:2014-12-15 21:44:43
【问题描述】:

我已经使用webdriver-manager start 启动了一个服务器,但是当我尝试运行量角器时出现此错误:

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

我的配置文件如下所示:

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

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

};

我还尝试指向功能对象中的二进制文件以及添加 chromeDriver 和 seleniumServerJar 键均无济于事。有什么想法吗?

【问题讨论】:

    标签: javascript google-chrome testing protractor end-to-end


    【解决方案1】:

    根据relevant github issue,问题是chromedriver找不到chrome浏览器可执行 - 在不同的操作系统上它在different places中搜索它。

    您需要在chromedriver 期望的位置安装chrome,或者在binary 设置中指定chrome 可执行文件的路径:

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

    【讨论】:

    • 谢谢!我试图将“二进制”放在“功能”中……不知道它应该在“chromeOptions”中
    【解决方案2】:

    我使用 JHipster 生成了代码,并且在 e2e 不工作的地方出现了类似的错误。我提供了二进制路径。但是在npm run e2e 浏览器打开并在地址栏中显示data;

    我在 args 之后的 chromeOptions 末尾打乱并提供了二进制文件,它起作用了。

    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"
            }
        }
    

    注意:当出现不支持的 webdriver 版本错误时,我还必须更新 chrome 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-09
      • 2017-12-01
      • 1970-01-01
      • 2023-03-10
      • 2010-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多