Search code examples
seleniumselenium-webdriverfirefox-addonbrowser-extension

Error on adding extension to FirefoxProfile


After searching I found a way to add extension to the Firefox via .FirefoxProfile(). However, the same solution is mentioned everywhere.

I don't understand why I am facing an error. Here is the code:

 String firebugFilePath = "C:\FF_addons\firebug.xpi";
        FirefoxProfile profile = new FirefoxProfile();
        try {
            profile.addExtension(new File(firebugFilePath));
            // Add more FF addons if required 
        } catch (IOException err) {                
        }
        driver = new FirefoxDriver(profile);

Error I am facing is on the 4th line: incompatible types: com.gargoylesoftware.htmlunit.javascript.host.file.File cannot be converted to java.io.File.


Solution

  • It sounds like you are importing the wrong File class.

    change your

    import com.gargoylesoftware.htmlunit.javascript.host.file.File
    

    to

    import java.io.File