How to add the Firebug extension on Firefox Browser?

We can add the extension's on Firefox Browser while executing the selenium scripts.  As all we knew, We will use FIREBUG extension to find the WebElement such as id, name, classname, etc.,

By default, when the selenium script invokes the Firefox Browser there will not be any extension's or plug-in's, will not be incorporated.  We need to specifically mention to add it in the firefox profile.

FirefoxDriver launches a new firefox browser whenever it is invoked.

In order to add the Firefox extension, we can use public void addExtension(java.io.File extensionToInstall) throws java.io.IOException.  For Example, Firebug has the extension with .XPI file.

Click to Download the Firebug extension : FireBug Extension and Save it in your local drive.
Example, C:\Firefox_Extensions\firebug-3.0.0-fx.xpi

Assume, I had saved in my local drive under Firefox_Extensions folder.  You can download latest version.

Firefox extension should be added through the FirefoxProfile() class.

Try the below code.
public class AddExtensionToProfile {
public static void main(String... args){
FirefoxProfile profile = new FirefoxProfile();
try
{
profile.addExtension(new File("C:\\Firefox_Extensions\\firebug-3.0.0-fx.xpi"));
} catch (IOException e) {
e.printStackTrace();
}
FirefoxDriver driver = new FirefoxDriver(profile);
}
}

No comments:

Post a Comment

Socialize It and Share the post with your friends
SOCIALIZE IT →
FOLLOW US →
SHARE IT →