【问题标题】:How selenium webdriver can enable the Firefox addons?selenium webdriver 如何启用 Firefox 插件?
【发布时间】:2017-12-30 18:50:44
【问题描述】:

在 selenium webdriver 中运行我的 java 脚本时,我能够在 FF 上看到插件(browsec VPN)图标,但在 FF 实例上始终禁用 VPN 插件 - 我已使用以下代码访问插件;

    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();

我可以看到执行上述代码的 browsec VPN 图标,但它处于禁用形式,我的问题是如何使用 selenium webdriver 启用它。谢谢

【问题讨论】:

    标签: java selenium-webdriver firefox-addon automated-tests vpn


    【解决方案1】:

    您需要使用“setPreference”来启用它,我在一些测试中使用了 firebug,并指定了它需要以下内容的插件路径:

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

    它可能与您的插件的首选项名称不完全相同,但如果您在安装插件时在地址栏中键入“about:config”并搜索“扩展”,则应该会找到类似的名称。在那里找到你的插件。只需在初始化驱动程序之前添加它,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2011-11-20
      • 2015-11-27
      • 2015-02-28
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      • 2017-04-26
      相关资源
      最近更新 更多