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

Fail to set the firefox profile #95

Closed
thomas-lee opened this issue Sep 9, 2017 · 5 comments
Closed

Fail to set the firefox profile #95

thomas-lee opened this issue Sep 9, 2017 · 5 comments

Comments

@thomas-lee
Copy link

thomas-lee commented Sep 9, 2017

Tried to show the default homepage on firefox.
But it didn't show the home page and it seems the options is not set. Any idea?

Env:
FIREFOX_VERSION=55.0.3
GECKODRIVER_VERSION=0.18.0
selenium 3.5.3-astatine
using this docker image https://hub.docker.com/r/selenium/node-firefox/

import wd from 'wd';
import FirefoxProfile from 'firefox-profile';

const serverConfig = {
  host: 'localhost',
  port: 7101,
};

const capabilities = {
  browserName: 'firefox',
  platform: 'ANY',
  version: ''
};

const fp = new FirefoxProfile();
fp.setPreference('browser.startup.homepage', 'http://google.com');
fp.updatePreferences();

fp.encoded((err, zippedProfile) => {
    if (err) {
        console.error('oops, an error occured:', err);
        return;
    }
    capabilities.firefox_profile = zippedProfile;
    const driver = wd.promiseChainRemote(serverConfig);
    driver.init(capabilities);
});
@saadtazi
Copy link
Owner

saadtazi commented Sep 9, 2017

I assume that you are using geckodriver and a modern version of firefox?

If that's the case, after fighting with geckodriver and selenium-server (the key thing is to have geckodriver in the PATH), I figured that the prefs are now the following:

fp.setPreference('browser.startup.homepage', 'http://saadtazi.com');
fp.setPreference('browser.startup.page', '1'); // defaults to 0, which means 'Blank Page'

Note that browser.startup.page seems to correspond to the following dropdown:
image

and that the profile needs to be placed under moz:firefoxOptons:

{
      browserName:'firefox',
      marionette: true,  // <-- it took me a while to figure out this one too!
        // firefox_profile: zippedProfile // <-- Not here...
        'moz:firefoxOptions': {
          profile: zippedProfile  // <-- ... but here
        }
      }

I hope it helps.

@saadtazi
Copy link
Owner

saadtazi commented Sep 9, 2017

Note that I updated examples/example-wd.js in master (+ added some hints in the README)

Feel free ask any questions, or close the issue if this works for you.

@thomas-lee
Copy link
Author

thomas-lee commented Sep 10, 2017

Thanks a lot, i can set the profile right now.

FYI, it seems firebug is deprecated and it seems need to sign or sth or firebug is a legacy extension.
So it won't enable/open the firebug automatically according to your sample firefox profile preference in the latest firefox version.

Btw, i want to extract the browser console log from firefox just like chrome.
I saw firefox is not currently supported with the webdriver API completely, so I can't get log (type browser) from the webdriver API directly.
SeleniumHQ/selenium#1161

I am not sure if i can get the browser log in other ways.
I saw there are capabilities and example online about preferences.
https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities

fp.setPreference("webdriver.log.file", "/tmp/firefox_console");
I can't find any files generated.

Also tried with

fp.setPreference('webdriver.log.driver', 'DEBUG');
fp.setPreference('marionette.logging', 'DEBUG');
fp.setPreference('extensions.logging.enabled', true);
fp.setPreference('webdriver.firefox.logfile', '/tmp/ff_log');

Do you have any ideas how i can get the firefox browser log from standalone selenium running with firefox driver (need to capture and send back to the client) ?

Is it possible to override the console method and get it back using js later ?

Another question is about fp.setPreference('saadt.coucou', 'console');
I don't understand what its usage..to get console ?

Thanks

@saadtazi
Copy link
Owner

Not sure how to get the log writen to a file, but there is a selenium command that allows to retrieve the log by type: POST /session/:sessionId/log (corresponding wdjs method: .log(type). Check here: https://github.com/admc/wd/blob/master/doc/api.md (i didn't test it myself...)

Note that there is a pending issue re: geckodrivee and error log: mozilla/geckodriver#330

@thomas-lee
Copy link
Author

Thanks for your information.

I have tried getLogType api, only 'server' is returned.

So it looks we can't get firefox browser log directly right now.

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