2017-02-21 28 views
0

我之前使用过directConnect,我可以指定firefoxPath来启动特定的二进制文件。现在,directConnect不再适用于Firefox> 47,我正在切换到使用木偶,firefoxPath不再工作。如何使用量角器和木偶指定firefox二进制文件的路径?

这是我的量角器配置看起来像现在。

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。

回答

-1

,如果你使用的是最新版本的Firefox,你需要为geckodriver属性下面是在Java代码

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

希望这会有所帮助,如果有这方面的问题,请发表评论,高兴地帮助:)

+0

我想将路径设置为firefox二进制文件,而不是壁虎驱动程序。我也在Node中使用Protractor,而不是Java。 –

相关问题