Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working version of custom firefox profile #26

Open
marklagendijk opened this issue Feb 18, 2019 · 3 comments
Open

Working version of custom firefox profile #26

marklagendijk opened this issue Feb 18, 2019 · 3 comments

Comments

@marklagendijk
Copy link

marklagendijk commented Feb 18, 2019

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];
        })
@marklagendijk
Copy link
Author

marklagendijk commented Feb 18, 2019

Note: I fixed the current example of this repo in #28.

@mderouet
Copy link

Hi, have you got a working example or sample project of using custom preferences of firefox instance driven by protractor... I would be awesome

@marklagendijk
Copy link
Author

marklagendijk commented Aug 2, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants