1

I'm trying to use a custom profile in Firefox with an add-on, I can open the profile, launch URL, I even see the add-on icon on top bar but is always set into the disabled mode, I need to set it to active all time. The add-on is 'anonymous' below is what I did, but no success.

public class SeleniumScript {
    static WebDriver driver;
    public static void main(String args[]) throws Exception {
System.setProperty("webdriver.gecko.driver", "E:\\Library\\geckodriver-v0.21.0-win32\\geckodriver.exe");
            ProfilesIni profile2 = new ProfilesIni();
            FirefoxProfile profile3 = profile2.getProfile("AutoProfile");
            FirefoxOptions firefoxOptions = new FirefoxOptions();
            firefoxOptions.setProfile(profile3);
            File file = new File("C:\\Users\\xxx\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\vjo848oc.AutoProfile\\extensions\\[email protected]");
            profile3.addExtension(file);
            profile3.setPreference("extensions.anonymox.currentVersion", "4.1"); 
            driver = new FirefoxDriver(firefoxOptions);
            String baseURL = "http://abc.com";
            driver.get(baseURL);
            driver.manage().window().maximize();
            }
    }

3 Answers 3

0

From firefox version 57 and above, only extensions built using WebExtensions APIs will work. You are using an xpi based add-on, that might be the reason of your issue. Please go thru the below link; might help!

https://support.mozilla.org/en-US/kb/find-and-install-add-ons-add-features-to-firefox#w_what-types-of-add-ons-can-i-install

0

It looks like you are using Selenium WebDriver to launch Firefox with a custom profile that has the Anonymox extension installed. The extension is being installed, but it is being disabled when the browser starts.

One reason the extension might be disabled is if it is incompatible with the version of Firefox that you are using. You can check the version of Firefox by going to Help > About Firefox in the browser menu. You can then check the extension's documentation or support resources to see if it is compatible with your version of Firefox.

Another reason the extension might be disabled is if it has been flagged as malicious or unsupported by Firefox. In this case, you will need to contact the extension's developer to resolve the issue.

You can also try setting the extensions.autoDisableScopes preference to 0 in the Firefox profile to allow the extension to run. You can set this preference by adding the following line to your code:

profile3.setPreference("extensions.autoDisableScopes", 0);

This will prevent Firefox from automatically disabling the extension when it starts.

0

To launch Firefox Geckodriver with an add-on enabled, you can use the following steps:

1 Set the system property for geckodriver

System.setProperty("webdriver.gecko.driver", "path_to_geckodriver.exe");

2 Get the custom profile and add the extension

ProfilesIni profile2 = new ProfilesIni();
FirefoxProfile profile3 = profile2.getProfile("AutoProfile");
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(profile3);
File file = new File("path_to_extension.xpi");
profile3.addExtension(file);

3 Set the extension preference, for example:

profile3.setPreference("extensions.anonymox.currentVersion", "4.1"); 

4 Launch the browser with the options

driver = new FirefoxDriver(firefoxOptions);

5 Navigate to a URL and maximize the window

String baseURL = "http://www.example.com";
driver.get(baseURL);
driver.manage().window().maximize();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.