-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Enable Firebug in Firefox for Nightwatch tests
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.
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.
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:
- Type
about:config
to access the "under the hood" settings; - Set
network.http.use-cache
tofalse
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.
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"
}
}
}
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.