Time for action – installing the add-on - Selenium

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:

What just happened?

We have just installed a Firefox add-on into the browser before we run our test. This is much simpler than it used to be in Selenium Remote Control where we would need to load the profile manually and make the changes that we needed and then run our tests telling Selenium Server to use this profile. The old process is not very portable compared to what we just did.

So far we have learnt to load Firefox and make changes to the browser before it loads which can be quite useful if we need to get more information out of the browser or make debugging issues a lot simpler.

Have a go hero - installing Firebug and not loading the First Run page

A lot of people like to use Firebug with WebDriver but get really annoyed with the First Run page.

  1. To get around this, we are going to have to update the version of Firebug in your Firefox Preferences.

  2. We will set the version to 99.9:


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics