如何从命令行覆盖 protractor.conf.js 值?

我目前有量角器设置可以在我们的集成服务器上运行.在 protractor.conf.js 文件中,我有以下内容:

I currently have protractor setup to run on our integration server. Inside the protractor.conf.js file i have the following:

 multiCapabilities: [{
    'browserName': 'firefox',
    'platform': 'MAC'
  }, {
    'browserName': 'chrome',
    'platform': 'MAC'
  }]

我想在从命令行本地运行时覆盖它.我试过以下没有成功

I would like to override this when running locally from the command line. I've tried the following with no success

protractor --verbose --browser=chrome

问题:从命令行本地运行时,如何切换到仅使用单个 chrome 实例?

Question: How do i switch to only using a single instance of chrome when running locally from the command line?

推荐答案

这是个问题.

根据源码,浏览器 命令行参数是 capabilities.browserName 的别名.

According to the source code, browser command line argument is an alias of capabilities.browserName.

根据 referenceConf.js 文档:

According to the referenceConf.js documentation:

// If you would like to run more than one instance of WebDriver on the same
// tests, use multiCapabilities, which takes an array of capabilities.
// If this is specified, capabilities will be ignored.
multiCapabilities: [],

换句话说,由于指定了 multiCapabilitiescapabilities 将被忽略.

In other words, since multiCapabilities are specified, capabilities are ignored.

您可以尝试从命令行重置 multiCapabilities:

What you can try to do is to reset multiCapabilities from command-line:

protractor --verbose --browser=chrome --multiCapabilities

作为另一种解决方法,使用单独的配置文件来运行单个浏览器实例.

As an another workaround, have a separate config file for running a single browser instance.

另外,相关主题列表:

  • 添加了对 multiCapabilities 对象和 splitTestsBetweenCapabilities 布尔值的支持
  • Multicapabilities 规范忽略命令行上的 --specs 标志并继续运行

相关文章