Skip to content

Enable Firebug in Firefox for Nightwatch tests

Andrei Rusu edited this page Oct 6, 2015 · 5 revisions

Selenium by default creates a new Firefox profile when starting Firefox. Often it is useful to be able to debug with Firebug while running your tests. To be able to do that we need to create our own Firefox profile and tell Selenium to use that one. Once we have a separate profile just for the tests we can configure it, part of which is to install the Firebug add-on.

1) Create a new Firefox profile:

Launch the firefox from the command-line with the -p switch:

  • on Mac OS X:
/Applications/Firefox.app/Contents/MacOS/firefox-bin -p
  • on Windows:
C:\"Program Files (x86)"\"Mozilla Firefox"\firefox -p

Chose the "Create Profile" option in the dialog that appears and give this profile a name that makes sense, for instance: "nightwatch".

For more info on Firefox profile management head on to: https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles.

2) Configure the new profile

Start Firefox with the newly created profile as shown in the previous step.

  • Install Firebug via the Add-ons utility;
  • It is recommended to disable the cache so that the tests will always run against a fresh copy of your code.

Here's how to do this:

  1. Type about:config to access the "under the hood" settings;
  2. Set network.http.use-cache to false

Setting Firebug options If you want to persist the Firebug panels you can do that also inside about:config. Here's the options you need to set depending on your needs:

  • Console panel: extensions.firebug.console.enableSites
  • Script panel: extensions.firebug.script.enableSites
  • Net panel: extensions.firebug.net.enableSites
  • Cookies panel: extensions.firebug.cookies.enableSites

If you want Firebug to show up by default check the option On for All Web Pages from the Firebug menu.

Exit Firefox for now.

3) Configure Nightwatch to use the new profile

Using nightwatch.json

Open your nightwatch.json file and in your configure your selenium cli_args settings as detailed here: http://nightwatchjs.org/guide#selenium-settings. For the firefox profile you need to define webdriver.firefox.profile, e.g.:

"selenium" : {
  "cli_args" : {
    "webdriver.firefox.profile" : "nightwatch"
  }
}

You can also define the cli_args per environment, like so:

"test_settings" : {
  "default" : {
    "cli_args" : {
      "webdriver.firefox.profile" : "nightwatch"
    }
  }
}

When running selenium-server-standalone.jar manually

Add -Dwebdriver.firefox.profile=webdriver to the command line arguments. E.g.: /usr/bin/java -jar /opt/selenium/selenium-server-standalone-2.46.0.jar -Dwebdriver.firefox.profile=webdriver

That should do it.

-- TIP: If you need to suspend the test to be able to inspect or debug the page you can use pause() in your test. Not passing any arguments will suspend the page indefinitely.