views:

113

answers:

2

What's the best way to activate firebug in firefox when running Selenium 2 ?

Edit: Ok, I realize "best" is open to interpretation, but the profile-based solution really used to be a pain with selenium 1.0. So any alternative is considered better until proved worse ;)

+3  A: 

Do you mean having firebug installed in the browser instance that webdriver launches? If so, you can pass an extension when you instantiate the driver, but the eaisest way is to create a firefox profile with firebug installed and then use the following code before you instantiate the driver:

System.setProperty("webdriver.firefox.profile", "NAME_OF_FIREFOX_PROFILE_WITH_FIREBUG");

Bill
This is more or less the way it was done in 1.0 and it always turned out to be a hassle when firefox was upgraded. I'd really like to pass in the extension....
krosenvold
+4  A: 

You can create your profile in code and dynamically add required add-ons. Let's assume that you saved Firebug XPI into the C:\FF_Profile folder as firebug.xpi (go to Firebug download page, right-click on the "Add To Firefox" ans save as C:\FF_Profile\firebug.xpi).

In code:

   final String firebugPath = "C:\\FF_Profile\\firebug.xpi";
   FirefoxProfile profile = new FirefoxProfile();       
   profile.addExtension(new File(firebugPath));
   // Add more if needed
   WebDriver driver = new FirefoxDriver(profile);

This is described in WebDriver FAQ

ZloiAdun
Your exmple is somewhat better than the faq, thanks !
krosenvold
This is totally awesome +100 if I could. Makes migrating to selenium2 worth it by itself
krosenvold
There are many things is Selenium2 that payoff the time spend for migration. Personally I found that Page Objects pattern is very convenient and makes testing of dynamic/AJAX web apps much easier. So I am really in love with WebDriver :)
ZloiAdun