How To Add Extensions (Firebug & Firepath) To The Instantiated FirefoxDriver


In general when we Instantiate a Firefox Webdriver, the extensions(firebug,firepath) would not be added in that browser. In order to add them we can set firefox preferences by downloading XPI’S.

What is XPI A file with the extension XPI (pronounced zippy ) contains a Firefox browser extension.These are very similar to zip files.

FireBug XPI Download from here,Place it in your drive.

FirePath XPI :Download from here,Place it in your drive.

You can also view the actual response time for each and every request sent to your application.And you can also get the cookies present.

Here i am sharing the code

import java.io.File;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.testng.annotations.Test;

public class AddExtensions{
private static WebDriver fd;

@Test
public void ms() throws Exception {
final String firebugPath = “D:\\firebug-1.12.0.xpi”;
final String firepathPath = “D:\\firepath-0.9.7-fx.xpi”;
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(new File(firebugPath));
profile.addExtension(new File(firepathPath));
String ext = “extensions.firebug.”;
String ext1 = “extensions.firepath.”;
//you need to Set default Firebug preferences and FirePath preferences
profile.setPreference(ext + “currentVersion”, “2.0.9”);
profile.setPreference(ext1 + “currentVersion”, “0.9.7”);
profile.setPreference(ext + “allPagesActivation”, “on”);
profile.setPreference(ext + “defaultPanelName”, “net”);
// profile.setPreference(ext + “defaultPanelName”, “cookies”);
profile.setPreference(ext + “net.enableSites”, true);
//profile.setPreference(ext + “cookies.enableSites”, true);
fd = new FirefoxDriver(profile);
fd.manage().window().maximize();
fd.get(“https://seleniumbycharan.wordpress.com”);
}
}

Now you can see Firebug and Firepath extension added to the browser.You can also see the response in ‘NET’ Panel.Please remove the comments in the code to get cookies too.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s