Tuesday, March 27, 2012

Using Firebug with Watir-Webdriver on Windows

I wrote some tests using watir-webdriver in IE, and when I ran them in Firefox, I had issues.  Sadly, I could not get Firebug to come up.  It seemed to be disabled.  Doing some research indicated that I needed to create a profile that could use Firebug.  It took some digging, but I finally got it to work.

The elusive firebug.
1.) Download the firebug.xpi file from https://addons.mozilla.org/en-US/firefox/addon/firebug/ by right-clicking on the + Add to Firefox button and saving the file.
2.) Place the firebug.xpi file in the root directory of your cucumber (or watir-webdriver) directory - the same level as your cucumber.yml.  (I did this just so I wouldn't have / \ issues going between linux and Windows.  It's a quick and dirty solution.)
3.) Add the following code to your env.rb or wherever you are instantiating your browser object:

    debug_profile = Selenium::WebDriver::Firefox::Profile.new
    debug_profile.add_extension "firebug-1.9.1-fx.xpi"
    browser = Watir::Browser.new :firefox, :profile => debug_profile 

Now when you run watir-webdriver, you will find you have Firebug available.

One gotcha I encountered was I saved the firebug.xpi file using Chrome.  It was corrupted, and I was getting an error about the zipfile not having an end.  So if you see that, re-download the file.  Preferably using Firefox.

No comments:

Post a Comment