2017-02-21 24 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。 –

相關問題