How To Attach Firebug and FirePath Add-On To Firefox Driver Instance

Firebug and FirePath add-ons of Firefox browser are playing major role to get the XPath and CSS path of any element easily and quickly. Earlier we learnt how to use firebug and firepath add-on with Firefox browser to get XPath or CSS of any element In THIS POST. Now supposing I need both
these add-ons In Firefox Driver Instance when I run my test using selenium WebDriver FirefoxDriver Instance. Is It possible? Yes - Let's see how can we do It.

As you know, It Is launching Firefox browser Instance with fresh profile every time when you execute selenium WebDriver test. So Firebug and FirePath will be not available In that fresh created profile of WebDriver FirefoxDriver Instance. Bellow given steps will add Firebug and FirePath In WebDriver FirefoxDriver Instance for you.

Download .xpi files of Firebug and FirePath add-on
First of all we need to download .xpi files of Firebug and FirePath add-on and then we will attach both these files with WebDriver FirefoxDriver Instance profile during test execution.

Download latest .xpi file of Firebug
You need Google Chrome or Internet Explorer browser to download .xpi file.

  • Open Google Chrome browser.
  • In Google Chrome browser, Go to Firebug add-on DOWNLOAD PAGE.
  • Click on "Download Now" button on Firebug add-on download page as shown In bellow Image.
  • Click on "download anyway" link as shown bellow. It will download .xpi file of firebug.
Download latest .xpi file of Firebug
  • Open Chrome browser.
  • In Chrome browser, Go to Firepath add-on DOWNLOAD PAGE.
  • Click on "Download Now" button and then click on "download anyway" link. firepath's .xpi file will be downloaded.
Current latest version of firebug Is 2.0.10 and firepath Is 0.9.7.1.1 so downloaded file will be "firebug-2.0.10-fx.xpi" and "firepath-0.9.7.1-fx.xpi". Firebug and FirePath versions can be change In future so file name will be different In future based on version.

Put firebug and firepath .xpi files In D: drive.

Create and run WebDriver test with firebug and firepath add-on
Now we can launch FirefoxDriver Instance with firebug and firepath add-on. We will create custom FirefoxDriver profile on run time and then attach both these add-ons with that custom profile. So new launched FirefoxDriver Instance will have firebug and firepath add-ons.

Execute bellow given test In your eclipse and verify firefox driver Instance Is launched with firebug and firepath add-ons or not.

package Testing_Pack;

import java.io.File;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;

public class Firebug {
 public static void main(String[] args) throws IOException {

  // Set Firebug and Firepath xpi file's path.
  // Note : both file's name and path should be proper. Please verify It twice.
  File firebug_path = new File("D:\\firebug-2.0.10-fx.xpi");
  File firepath_path = new File("D:\\firepath-0.9.7.1-fx.xpi");

  // Create firefox driver Instance profile.
  FirefoxProfile firefoxprofile = new FirefoxProfile();

  // Add Firebug add-on to new created profile of Firefox browser.
  firefoxprofile.addExtension(firebug_path);

  // Add FirePath add-on to new created profile of Firefox browser.
  firefoxprofile.addExtension(firepath_path);

  // Pass new created Firefox profile to the FirefoxDriver instance.
  WebDriver driver = new FirefoxDriver(firefoxprofile);
  driver.get("http://only-testing-blog.blogspot.com/2014/04/calc.html");
 }
}

When I run above test, my firefox driver Instance Is launched with firebug and firepath add-ons as shown In bellow Image.


This way you can use firebug and fire path add-on run time to get XPath of any element when you run your tests. THIS POST will show you how to get xpath or CSS path using firebug and firepath.

7 comments:

  1. I am able to use the firebug and firepath by opening browser manually and clicking its icon on top of browser.
    But using the script above, it doesn't work. After browser opens, the firebug is deactivated. And I can't event activate the icon.
    Before that, I have also to input the proxy username and password.
    Do you have any idea of what is the problem?
    I tried putting implicitWait of 30 to delay the opening of website to give time for username and password input.

    I am just wandering why proxy dialog always show via opening from your selenium sample codes. I am thinking that with that all addons have been deactivated.

    ReplyDelete
  2. Hi Aravind,

    It is grate place to learn though your knowledge. tons of thanks.

    As mentioned by Mark above, me too facing the same problem and no hint of problem for not working!!

    ReplyDelete
  3. Hello,

    I have the exact code and can launch Firefox with firebug fine but firepath does not show up for me. Do you know why that might be?

    So all the code is running but no firepath but only firebug.

    ReplyDelete
  4. Here is my code for reference:
    String firebugPath = ProjectRootFolder+"\\library\\firebug-3.0.0-alpha.14.xpi";
    String firepathPath = ProjectRootFolder+"\\library\\firepath-0.9.7.1-fx.xpi";

    //Create a new Profile for the new settings
    FirefoxProfile profile = new FirefoxProfile();
    // Pass the XPIs path to the profile
    profile.addExtension(new File(firebugPath));
    profile.addExtension(new File(firepathPath));

    //Set default Firebug preferences and FirePath preferences
    String ext = "extensions.firebug.";
    String ext1 = "extensions.firepath.";

    profile.setPreference(ext + "currentVersion", "3.0.0");
    profile.setPreference(ext1 + "currentVersion", "0.9.7");
    profile.setPreference(ext + "allPagesActivation", "on");
    profile.setPreference(ext + "defaultPanelName", "net");
    profile.setPreference(ext + "net.enableSites", true);

    ReplyDelete
  5. For the record I tried using full file paths to see if it make a difference and still I get Firebug but no FirePath !

    ReplyDelete
  6. Hi, Aravind
    Mayby the URL to get firepath now is
    https://addons.mozilla.org/en-US/firefox/addon/firepath/

    The URL now on this post leads to a page quite different with the page in this post.

    Mak

    ReplyDelete