BrowserMob代理不会将https资源列入黑名单

时间:2016-07-07 17:54:08

标签: java selenium-webdriver proxy browsermob browsermob-proxy

我正在使用代理来排除第三方资源。但是我对所有以https开头的资源都有问题。你能建议任何解决方案吗? 例如,我试图从get_object_vars中排除static.licdn.com。它会更改状态,但会下载资源。

   public void setUp()    
    throws Exception
{
    setName("test");
    try
    {
        FirefoxBinary firefoxbinary = new FirefoxBinary(new File("firefoxpath"));
        File file = new File("profilePath");
        FirefoxProfile firefoxprofile = new FirefoxProfile(file);
        firefoxprofile.setPreference("browser.startup.homepage", "http://www.google.com");
        BrowserMobProxyServer server = new BrowserMobProxyServer();
        server.start();
        ArrayList arraylist = new ArrayList();
        arraylist.add(new BlacklistEntry(".*static\\.licdn\\.com.*", 204));
        server.setBlacklist(arraylist);
        org.openqa.selenium.Proxy proxy = ClientUtil.createSeleniumProxy(server);
        proxy.setSslProxy("localhost:" + server.getPort());
        DesiredCapabilities desiredcapabilities = new DesiredCapabilities();
        desiredcapabilities.setCapability("proxy", proxy);
        desiredcapabilities.setCapability("acceptSslCerts", true);
        driver = new FirefoxDriver(firefoxbinary, firefoxprofile, desiredcapabilities);
    }
    catch(Throwable throwable)
    {
        LOG.error("Problem in setup: ", throwable);
    }
}
  • 浏览器暴徒版:2.1.1
  • 硒版本:2.53
  • FF版本:46

1 个答案:

答案 0 :(得分:0)

解决方案 - 我们只是编写我们的自定义插件来排除第三方库。不幸的是,由于项目政策,我无法分享我的代码。