Sunday, January 27, 2013

Selenium, FireFox, Firebug and NetExport

How do you get the firebug enabled in Firefox for your selenium tests?

Step 1: Download Firebug and the add-on net
Step 2: Initialize a new FireFoxProfile and add the extensions to the location of the .xpi files for firebug and net export
Step 3: One key statement that I initially missed was:
profile.SetPreference("extensions.firebug.allPagesActivation", "on"); 

Step 4: Enable the auto export property and give the location information

Below is complete code:


               
        [ClassInitialize]
        public void SetupProfile()
        {
            FirefoxProfile profile = new FirefoxProfile();
            try
            {
                profile.AddExtension(@"C:\LocalMachineUser\AppData\Roaming\Mozilla\Firefox\Profiles\0z8cb853.default\extensions\firebug@software.joehewitt.com.xpi");
                profile.AddExtension(@"C:\LocalMachineUser\AppData\Roaming\Mozilla\Firefox\Profiles\0z8cb853.default\extensions\netexport@getfirebug.com.xpi");
            }
            catch (IOException ioe)
            {
                Console.WriteLine("Exception occurred loading the profile files " + ioe.Message); 
            }
            profile.SetPreference("extensions.firebug.currentVersion", "1.11.1");
            profile.SetPreference("extensions.firebug.previousPlacement", 1);
            profile.SetPreference("extensions.firebug.onByDefault", true);
            profile.SetPreference("extensions.firebug.defaultPanelName", "net");
            profile.SetPreference("extensions.firebug.net.enableSites", true);
            profile.SetPreference("extensions.firebug.allPagesActivation", "on"); 
            profile.SetPreference("extensions.firebug.netexport.defaultLogDir", @"D:\TestFiles\_HAR");
            profile.SetPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
            driver = new FirefoxDriver(profile);
            baseURL = "https://companyurl";
            verificationErrors = new StringBuilder();
        }


No comments: