【问题标题】:How do I specify the path to the firefox binary using protractor and marionette?如何使用量角器和木偶指定 Firefox 二进制文件的路径?
【发布时间】:2017-02-21 00:56:34
【问题描述】:

我之前使用的是 directConnect,我可以指定 firefoxPath 来启动特定的二进制文件。现在 directConnect 不再适用于 Firefox > 47,我将切换到使用 marionette 并且 firefoxPath 不再适用。

这就是我的量角器配置现在的样子。

const firefox = require('selenium-webdriver/firefox');

const firefoxProfile = new firefox.Profile();

const config = {
  specs: ['e2e/scenarios.js'],
  seleniumAddress: 'http://localhost:4444/wd/hub',
  framework: 'jasmine',
};

switch (process.env.BROWSER) {
  case 'firefox':
    firefoxProfile.setPreference('media.navigator.permission.disabled', true);
    firefoxProfile.setPreference('media.navigator.streams.fake', true);
    firefoxProfile.setPreference('media.getusermedia.screensharing.allowed_domains',
      'localhost,adam.local');

    config.capabilities = {
      browserName: 'firefox',
      marionette: true,
      firefox_profile: firefoxProfile,
    };
    break;
  case 'chrome':
  default:
    config.capabilities = {
      browserName: 'chrome',
      chromeOptions: {
        args: ['auto-select-desktop-capture-source="Entire screen"',
          'use-fake-device-for-media-stream',
          'use-fake-ui-for-media-stream', 'disable-popup-blocking'],
        binary: process.env.BROWSERBIN,
      },
    };
    break;
}

exports.config = config;

这一切似乎都可以正常工作,即使指定了首选项,但我无法让浏览器二进制文件正常工作。我已经在功能中尝试了 firefoxPath 和 firefox_bin。两者似乎都不起作用。既然 webdriver-manager 正在启动浏览器,我在启动 webdriver-manager 时是否需要指定路径?

我正在使用量角器 5.1.1,webdriver-manager 12.0.2。

【问题讨论】:

    标签: selenium-webdriver protractor webdriver-io


    【解决方案1】:

    如果您使用的是最新版本的 firefox,则需要为 geckodriver 设置属性,下面是 java 中的代码

    System.setProperty("webdriver.gecko.driver","D:\\Jar's\\geckodriver-v0.11.1-win64\\geckodriver.exe");
            driver = new FirefoxDriver();
    

    希望对您有所帮助,如有任何问题,请发表评论,乐于帮助:)

    【讨论】:

    • 我想设置 firefox 二进制文件的路径,而不是 gecko 驱动程序。我也在 Node 中使用 Protractor,而不是 Java。
    猜你喜欢
    • 2021-06-17
    • 2017-09-26
    • 1970-01-01
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-01
    相关资源
    最近更新 更多