使用selenium webdriver配置,Firefox配置文件设置会在量角器中引发错误

时间:2015-07-30 04:22:08

标签: javascript selenium selenium-webdriver jasmine protractor

var q = require("q");
var FirefoxProfile = require("firefox-profile");
var makeFirefoxProfile = function(preferenceMap) {

    var deferred = q.defer();
    var firefoxProfile = new FirefoxProfile();

    for (var key in preferenceMap) {
        firefoxProfile.setPreference(key, preferenceMap[key]);
    };

    firefoxProfile.encoded(function (encodedProfile) {
        var capabilities = {
            browserName: "firefox",
            directConnect: true,
            firefox_profile: encodedProfile
        };

        deferred.resolve(capabilities);
    });
    return deferred.promise;
};


exports.config = {
   specs:specs,
   getMultiCapabilities: function() {
       return q.all([
           makeFirefoxProfile(
               {
                   "browser.download.folderList": 2,
                   "browser.download.dir": "/path/to/save/downloads",
                   "browser.helperApps.neverAsk.saveToDisk": "application/zip"
               }
           )
       ]);
   },

  // ...
}

它会抛出以下错误:

  

错误 - 加载配置文件protractor.conf.js失败   /usr/local/lib/node_modules/protractor/lib/configParser.js:183       扔掉;             ^错误:找不到模块'q'

请分享您的观点以解决此问题。

1 个答案:

答案 0 :(得分:0)

您需要安装qfirefox-profile个模块:

npm install q firefox-profile --save-dev