Browsermob代理+ chrome webdriver Https infinit lopp

时间:2015-11-19 10:45:15

标签: java selenium proxy chrome-web-driver browsermob-proxy

我正在使用Browsermob代理通过chrome webdriver捕获加载的网页的HAR内容。

  <dependency>
        <groupId>net.lightbody.bmp</groupId>
        <artifactId>browsermob-core-littleproxy</artifactId>
        <version>2.1.0-beta-3</version>
    </dependency>

以下是我如何初始化代理:

ChromeOptions options = new ChromeOptions();

    for (String extension : DriverProperties.CHROME_EXTENSIONS.getStringArray()) {
        options.addExtensions(new File(extension));
    }

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
    capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, false);
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);

    proxy = new BrowserMobProxyServer();
    proxy.start(0);

    proxy.setHarCaptureTypes(CaptureType.RESPONSE_CONTENT, CaptureType.RESPONSE_BINARY_CONTENT);


    // get the Selenium proxy object
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

    capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
    proxy.newHar();

    ChromeDriver driver = new ChromeDriver(capabilities); 

但是当我尝试通过https获取网址时(对于exapmle https://screen.yahoo.com),我在网络浏览器中看到“此网页有一个重定向循环”。对此有什么解决方案吗?

0 个答案:

没有答案