protractor-demo
protractor-demo copied to clipboard
Working version of custom firefox profile
The current example of using a custom firefox profile does not work.
The main issue is that it sets .firefox_profile instead of .moz:firefoxOptions.profile.
I created a helper that loads and encodes an existing profile, and returns a Promise:
firefox-profile-loader.js
const Promise = require('bluebird');
const FirefoxProfile = require('firefox-profile');
module.exports = {
getEncoded
};
function getEncoded({ profileDirectory, destinationDirectory }) {
return copy({ profileDirectory, destinationDirectory })
.then(encode);
}
function copy({ profileDirectory, destinationDirectory }) {
return new Promise((resolve, reject) => {
FirefoxProfile.copy({
profileDirectory,
destinationDirectory
}, (error, profile) => error ? reject(error) : resolve(profile));
});
}
function encode(profile) {
return new Promise((resolve, reject) => {
profile.encoded((error, profile) => error ? reject(error) : resolve(profile));
});
}
Example usage:
const path = require('path');
const firefoxProfileLoader = require('./firefox-profile-loader');
exports.config = {
directConnect: true,
specs: [
'spec.js'
],
framework: 'jasmine2',
getMultiCapabilities: () => firefoxProfileLoader
.getEncoded({
profileDirectory: path.resolve(__dirname, '../firefox-profile'),
destinationDirectory: path.resolve(__dirname, '../../tmp/firefox-profile')
})
.then(encodedProfile => {
const capabilities = {
'browserName': 'firefox',
'moz:firefoxOptions': {
profile: encodedProfile,
args: ['--headless']
}
};
return [capabilities];
})
Note: I fixed the current example of this repo in #28.
Hi, have you got a working example or sample project of using custom preferences of firefox instance driven by protractor... I would be awesome
Yes, see this pull request: https://github.com/juliemr/protractor-demo/pull/28
Op zo 28 jul. 2019 02:32 schreef Martin Derouet [email protected]:
Hi, have you got a working example or sample project of using custom preferences of firefox instance driven by protractor... I would be awesome
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/juliemr/protractor-demo/issues/26?email_source=notifications&email_token=AAJCBRZ7GKOKDJSDR2YYJFLQBTSKZA5CNFSM4GYDHJYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD26U72I#issuecomment-515723241, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJCBR5RQLPI6DAUMCKAFU3QBTSKZANCNFSM4GYDHJYA .