使用 Firefox 进行测试时出现二进制位置错误

问题描述 投票:0回答:1

我有这个带有一些测试的 github.js 文件:

module.exports = {
    const homeToLoginPage = () => {
      client
      .url(homeURL)
      ...
    };

    const incorrectLoginFlow = () => {
      client
      .waitForElementVisible(selectors.loginInputField, timeout)
      ...
    };

    homeToLoginPage();
    incorrectLoginFlow();
  }
}

当我用 Google Chrome 运行它时

npm test -- -t tests/github.js
一切正常,但是当我尝试用 Firefox 运行它时
npm test -- -t tests/github.js --env firefox
我收到此错误消息:“Expected browser binary location, but unable to find binary in default location, no提供“moz:firefoxOptions.binary”功能,但未设置二进制标志 在命令行”。

我检查过 firefox.exe 位于:C:\Program Files\Mozilla Firefox,这应该是 Windows 的默认设置。

还有相关的night.conf.js文件:

module.exports = {
  src_folders: ['tests'],
  webdriver: {
      start_process: true,
      port: 4444
  },
  test_settings: {
      default: {
          desiredCapabilities: {
              browserName: 'chrome'
          },
          webdriver: { server_path: require('chromedriver').path },
          
          'screenshots': {
            'enabled': true,
            'on_failure': true,
            'path': './screens'
          },

          'test_workers': {
            'enabled': false,
            'workers': 'auto'
          },
      },
      firefox: {
          desiredCapabilities: {
              browserName: 'firefox'
          },
          webdriver: { server_path: require('geckodriver').path }
      }
  }
}; 

我搜索了很多,发现有人试图更改 moz:firefoxOptions 中的某些 Firefox 功能以手动记录 firefox.exe 的路径,但我找不到在哪里可以做。请给出一些建议如何在 Firefox 浏览器中运行测试。

javascript firefox nightwatch.js geckodriver nightwatch
1个回答
0
投票

找到这个解决方案:将值添加到系统变量 PATH 中。 Firefox 默认文件夹和 geckodriver 文件夹也已添加到 PATH。 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.