设置 firefox 配置文件量角器
Set firefox profile protractor
我尝试使用此代码:
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
}
)
]);
},
但是显示错误:
错误:类型错误:profile.getTemplateDir 不是函数
我不知道如何解决它。
似乎 selenium-webdriver
(被 protractor
使用)用于接受 base64 编码的字符串 firefox_profile
能力 属性。但现在它需要一个 selenium-webdriver/firefox
.Profile
实例。下面是解决问题的方法:
// 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
软件包。
我尝试使用此代码:
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
}
)
]);
},
但是显示错误: 错误:类型错误:profile.getTemplateDir 不是函数 我不知道如何解决它。
似乎 selenium-webdriver
(被 protractor
使用)用于接受 base64 编码的字符串 firefox_profile
能力 属性。但现在它需要一个 selenium-webdriver/firefox
.Profile
实例。下面是解决问题的方法:
// 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
软件包。