acontell
acontell

Reputation: 6922

Setting up Selenium Firefox profile

Running our tests, we encountered a problem related to the way FireFox manages the events when the browser doesn't have the focus.

We found out that this problem can be solved setting up a FireFox profile with the preference "focusmanager.testmode" set to true (https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/157).

My question is, do you know of any other preference/capability/whatever that is worth having in our profile/configuration of the webdriver?

This could save us a lot of time in the future debugging strange problems/behaviours and I'd really appreciate any advise that you could give me.

Upvotes: 3

Views: 1167

Answers (2)

Andrew Regan
Andrew Regan

Reputation: 5113

Just to follow-up my comment, I'm quite anti- having a set of custom preferences / profile-settings:

  • to minimise differences between what's tested and what a regular user would see
  • to minimise browser-specific code
  • plus it can make diagnosing problems on sites like this more complex

In other words, I'd like Firefox (et al) to be a black box.

I'm all for Firefox bugs getting fixed, and perhaps even the default behaviour evolving over time, providing everyone is "on the same page". I think testing is complicated enough without people picking different workarounds.

Upvotes: 0

chrmod
chrmod

Reputation: 1445

Firefox has all sort of preferences that can be tweak to improve tests stability. But as pointed out by Andrew Regan changing anything may affect your tests so, may be not a best idea.

Anyhow this is a set of prefs I use to make tests fail less often due to unexpected browser behaviour:

// Disable checking if firefox is default browser
lockPref('browser.shell.checkDefaultBrowser', false);

// Disable restoring session
lockPref('browser.sessionstore.resume_from_crash', false);

// Disable updater
lockPref("app.update.enabled", false);
// make absolutely sure it is really off
lockPref("app.update.auto", false);
lockPref("app.update.mode", 0);
lockPref("app.update.service.enabled", false);

// Prevent closing dialogs
lockPref("browser.showQuitWarning", false);
lockPref("browser.warnOnQuit", false);
lockPref("browser.tabs.warnOnClose", false);
lockPref("browser.tabs.warnOnCloseOtherTabs", false);

// Disable Add-ons compatibility checking
clearPref("extensions.lastAppVersion");

// Don't show 'know your rights' on first run
pref("browser.rights.3.shown", true);

//Disable plugin checking
lockPref("plugins.hide_infobar_for_outdated_plugin", true);
clearPref("plugins.update.url");

// Disable health reporter
lockPref("datareporting.healthreport.service.enabled", false);

// Disable all data upload (Telemetry and FHR)
lockPref("datareporting.policy.dataSubmissionEnabled", false);

// Disable crash reporter
lockPref("toolkit.crashreporter.enabled", false);
Components.classes["@mozilla.org/toolkit/crash-reporter;1"].getService(Components.interfaces.nsICrashReporter).submitReports = false;

// Browser Console command line
pref("devtools.chrome.enabled", true);

To automate the process of setting up prefs you may like to use so called Firefox autoconfig file. Sample configuration: https://github.com/cliqz-oss/firefox-autoconfigs

Upvotes: 3

Related Questions