O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – installing the add-on

Imagine that you wanted to install Firebug so that if a test were to fail we could try and debug the JavaScript. To do this, we will need to create a FirefoxProfile and then tell it to add the add-on.

  1. Create a profile object:
    FirefoxProfile profile = new FirefoxProfile();
  2. Now we need to install the add-on. WebDriver can only install add-ons that are on the local hard drive:
    profile.addExtension("path/to/addon");
  3. Pass the profile into FirefoxDriver and then run your test. Your code would look like the following:
    public class TestChapter6 { WebDriver driver; @Before public void setUp(){ FirefoxProfile profile = new FirefoxProfile(); profile.addExtension("firebug.xpi"); driver = new FirefoxDriver(profile); driver.get("http://book.theautomatedtester.co.uk/chapter4"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required