Use NetExport to export Firebug’s NET panel

5 (100%) 1 vote

Problem

Firebug comes with a create feature which is visible in the NET panel. The NET panel gives use the per item download time in a breakdown structure. This structure is build up from a HAR file. This recipe shows us how we can export the HAR file from a code perspective.

Prerequisites

We have to download three firefox add-ons, before we can start implementing this. It is not mandatory to install the add-ons, we can also store them locally. The following three files are available from http://getfirebug.com/releases/ : firebug, NetExport and firestarter.

Solution

The following code can be used in the setup method to implement the NetExport measurements:

<code lang="java">
@BeforeMethod
public void setUp() {
    FirefoxProfile profile = new FirefoxProfile();
    try {
        profile.addExtension(new File("c:/firebug-1.7.2.xpi"));
        profile.addExtension(new File("c:/netExport-0.8b16.xpi"));
        profile.addExtension(new File("c:/fireStarter-0.1a6.xpi"));
    } catch (IOException e) {
        throw new RuntimeException("Could not load required extensions, did you download them to the above location? ", e);
    }
        profile.setPreference("extensions.firebug.currentVersion", "9.99");
        profile.setPreference("extensions.firebug.DBG_NETEXPORT", false);
        profile.setPreference("extensions.firebug.onByDefault", true);
        profile.setPreference("extensions.firebug.defaultPanelName", "net");
        profile.setPreference("extensions.firebug.net.enableSites", true);
        profile.setPreference("extensions.firebug.net.persistent", true);
        profile.setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
        profile.setPreference("extensions.firebug.netexport.autoExportToFile", true);
        profile.setPreference("extensions.firebug.netexport.autoExportToServer", false);
        profile.setPreference("extensions.firebug.netexport.defaultLogDir", "C:\\temp");
        profile.setPreference("extensions.firebug.netexport.showPreview", true); // preview.
        profile.setPreference("extensions.firebug.netexport.sendToConfirmation", false);
        profile.setPreference("extensions.firebug.netexport.pageLoadedTimeout", 1500);
        profile.setPreference("extensions.firebug.netexport.Automation", true);
    driver = new FirefoxDriver(profile);
    selenium = new WebDriverBackedSelenium(driver, "http://www.google.com");
}
</code>

Do not forget to update the paths to the latest version of the extensions. The code above is tested with Mozilla Firefox 3.6.

What has been done

The script will load three add-ons while launching the Firefox browser. Some parameters are set, like the default logging folder.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.