Firepath and FireBug are no longer supported by Mozilla and not available to download in recent versions. But almost the same features are present in the default developer tool, which can be open by pressing F-12.
All of us has noticed that when we instantiate a Firefox browser using Selenium, the extensions added to our normal Firefox browser are always missing from the FireFoxDriver. Why we need extensions loaded into FireFoxDriver, there can be any reason but most of the times while debugging the issue you put the breakpoints in your script and try to look for the locator’s value in the FireFoxDriver. But we can not do that because extensions are never loaded by default in FireFoxDriver.
In order to do that we can set Firefox preferences by downloading XPI’S.
What is XPI file?
The Mozilla Firefox browser uses XPI files to provide extendability in the browser. If you have an XPI file, just drag it to any open Firefox window to install. The XPI file is actually just a renamed ZIP file so any archive/compression program will open XPI files for expansion once it’s renamed from XPI to ZIP.
How to download XPIs?
Download XPIs is a very normal process. just go to the relevant page and download it to your hard drive.
FireBug XPI
1) Go to FireBug XPI download page and click on the latest version or the specific version you are looking for.
2) Once you click on the Version, it will open up a page for different releases of that version. Look for the recent alpha release and download it on your machine.
FirePath XPI
XPIs can be downloaded in another way as well.
1) Go to FirePath XPI download page. Right click on ‘Add to Firefox‘ and select ‘Save AS..‘ to save the XPI of the FirePath.
How to Add Extensions (Firebug & FirePath) to FirefoxDriver?
Time to load the saved extensions to FireFoxDriver.
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package ToolsQA; 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 FireFoxExtentions { private static WebDriver driver; public static void main(String[] args) throws IOException { //Save the path of the XPI files as per your saved location String firebugPath = "D:\\firebug-3.0.0-alpha.12.xpi"; String firepathPath = "D:\\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); driver = new FirefoxDriver(profile); driver.manage().window().maximize(); driver.get("http://forumsqa.com"); } } |
FireFox profile also can be created for the System browser, please have a look at this chapter as well Custom Firefox Profile for Selenium.