设置firefox配置文件量角器 [英] Set firefox profile protractor
本文介绍了设置firefox配置文件量角器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用此代码:
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",
firefox_profile: encodedProfile
};
deferred.resolve(capabilities);
});
return deferred.promise;
};
getMultiCapabilities: function () {
return q.all([
makeFirefoxProfile(
{
"browser.download.folderList": 2,
"browser.download.dir": "D:/Automation",
"browser.helperApps.alwaysAsk.force": false
}
)
]);
},
但它显示错误:
错误:TypeError :profile.getTemplateDir不是函数
我不知道如何解决它。
But it show error: Error: TypeError: profile.getTemplateDir is not a function I don't know how to fix it.
推荐答案
似乎 selenium-webdriver
(由 protractor
使用)用于接受base64编码的字符串 firefox_profile
功能属性。但现在它需要一个 selenium-webdriver / firefox
。 Profile
实例。以下是解决问题的方法:
it seems like selenium-webdriver
(which is used by protractor
) used to accept a base64 encoded string firefox_profile
capability property. But now it expects a selenium-webdriver/firefox
.Profile
instance. So here is how you can solve your issue:
// make sure you have access to the selenium-webdriver firefox Profile class
var FirefoxProfile = require("selenium-webdriver/firefox").Profile;
//...
// then change makeFirefoxProfile() function implementation with the following...
var makeFirefoxProfile = function (preferenceMap) {
var profile = new FirefoxProfile();
for (var key in preferenceMap) {
profile.setPreference(key, preferenceMap[key]);
}
return q.resolve({
browserName: "firefox",
marionette: true,
firefox_profile: profile
});
};
我希望这会有所帮助。
注意不再需要 firefox-profile
包。
这篇关于设置firefox配置文件量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文