有没有办法在nightwatch中指定firefox的可执行路径?

时间:2017-04-21 13:52:11

标签: javascript selenium firefox nightwatch.js

我使用夜视仪在Chrome和Firefox上运行测试。

一切都像Chrome上的魅力一样。我在我们的服务器上成功运行了Firefox测试,但我的机器上存在问题。

目前,由于Marionnette不是很稳定,我们使用 Firefox ESR 对我们的软件进行测试,而这种软件在没有任何驱动程序的情况下受到硒的支持。

在我的linux机器上,我安装了Firefox(最新)和Firefox(扩展支持版本)。

  • Firefox /usr/bin/firefox
  • 是可行的
  • Firefox ESR位于/usr/bin/firefox-es

使用量角器,我可以使用名为firefox_path的魔术属性指定要触发的可执行文件。

但我还没有找到如何使守夜人使用/usr/bin/firefox-esr

有什么想法吗?

我的配置,如果您有兴趣:

const seleniumPath = /*computed value*/;
module.exports = {
  "src_folders": ["test/e2e"],
  "output_folder": "reports/e2e",
  "detailed_output": false,
  "selenium": {
    "start_process": true,
    "server_path": seleniumPath,
    "log_path": "",
    "host": "127.0.0.1",
    "port": 4444,
    "cli_args": {},
  },
  "test_settings": {
    "default": {
      "launch_url": launchUrl,
      "exclude": ["utils/**/*", "gulpfile.js", "nightwatch*.js"],
      "selenium_port": 4444,
      "selenium_host": "localhost",
      "silent": true,
      "screenshots": {
        "enabled": true,
        "path": "reports/e2e/screenshots",
      },
      "desiredCapabilities": {
        "browserName": "firefox",
        "javascriptEnabled": true,
        "acceptSslCerts": true,
      },
    },
    "test_runner": {
      "type": "mocha",
      "options": {
        "ui": "bdd",
        "reporter": "spec",
      },
    },
  }

2 个答案:

答案 0 :(得分:1)

尝试此解决方案,让我知道它是否正在您的身边

    selenium: {
     cli_args: {
      'webdriver.gecko.driver': '/path/to/geckodriver'
    }
  },

    test_settings: {
      default: {
        desiredCapabilities: {
          browserName: 'firefox',
          marionette: true,
          javascriptEnabled: true
        }
    }

答案 1 :(得分:0)

我没有多个Firefox安装可供尝试,但我希望cli_args获取包含路径的webdriver.firefox.binary属性。

这将与其他Selenium Settings保持一致。当然,它作为webdriver文档中Firefox section的设置存在,并且GeckoDriver docs中存在相同的功能(虽然我感谢你并没有使用它)。

相关问题