【问题标题】:Is there a way to specify firefox's executable path in nightwatch?有没有办法在 nightwatch 中指定 firefox 的可执行路径?
【发布时间】:2017-04-21 13:52:10
【问题描述】:

我正在使用 nightwatch 在 Chrome 和 Firefox 上运行测试。

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

目前,由于 Marionette 不是很稳定,我们正在使用 Firefox ESR 测试我们的软件,该软件无需任何驱动程序即可获得 selenium 的支持。

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

  • Firefox 可在/usr/bin/firefox 中访问
  • Firefox ESR 在/usr/bin/firefox-es

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

但我还没有找到如何让nightwatch使用/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",
      },
    },
  }

【问题讨论】:

  • 你可以将selenium.start_process 设置为true,然后让守夜人来决定如何运行。

标签: javascript selenium firefox nightwatch.js


【解决方案1】:

试试这个解决方案,让我知道它是否对你有用

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

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

【讨论】:

  • 感谢您的回答。不幸的是,我不想使用壁虎驱动程序。我使用的是旧版本的 Firefox,它仍然受支持并且不需要 gecko 驱动程序。对此版本进行测试是可行的,因为这是我们在 Jenkins slave 上使用的版本。
  • @ghusse - 你希望如何在不使用网络驱动程序的情况下运行 selenium 测试(夜间守夜人会在幕后进行)?
  • Firefox 版本 ESR 不需要 Web 驱动程序:selenium 原生支持它。
【解决方案2】:

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

这将与另一个Selenium Settings 保持一致。当然,它作为 webdriver 文档中的 Firefox section 中的设置存在,GeckoDriver docs 中也有相同的功能(尽管我感谢您没有使用它)。

【讨论】:

  • 感谢您的回答。不幸的是,它似乎不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-05
  • 2012-09-16
  • 2020-12-04
  • 2021-04-20
相关资源
最近更新 更多