简体   繁体   中英

How selenium webdriver can enable the Firefox addons?

I am able to see the addon (browsec VPN) icon on FF while running my java script in selenium webdriver but the VPN addon is always disable on FF instance - I have used the following code to access addon;

    WebDriver driver = null;

    FirefoxProfile profile = new FirefoxProfile();
      File addonpath = new File("addonpath");
      profile.addExtension(addonpath);
     DesiredCapabilities capabilities = DesiredCapabilities.firefox();
     capabilities.setCapability(FirefoxDriver.PROFILE, profile);

     capabilities.setCapability("browsec", true);

      driver = new FirefoxDriver(profile);

      driver.get("application url");
      Thread.sleep(3000);
    driver.quit();

I can see the browsec VPN icon executing above code but It is in disable form, my question is how can I get it enabled using selenium webdriver. Thank you

You'd need to enable it using 'setPreference' I use firebug in some of my tests and along with specifying the addon path it needs the following:

profile.setPreference("extensions.firebug.onByDefault", true);

It may not be exactly the same preference name for your addon but there should be something similar you can find if you type "about:config" in the address bar when you have the addon installed and search for "extensions." in there and find your addon. Just add this in before you initialise the driver and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM