io.netty.handler.codec.TooLongFrameException:HTTP内容长度超过2097152字节。使用selenium和browsermob的例外情况

时间:2017-05-05 21:04:48

标签: selenium-webdriver browsermob browsermob-proxy

我最近在Chrome浏览器(selenium)上运行测试时开始看到下面的问题

io.netty.handler.codec.TooLongFrameException:HTTP内容长度超过2097152字节。     在io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:241)〜[netty-all-4.0.42.Final.jar:4.0.42.Final]     at io.netty.handler.codec.http.HttpObjectAggregator.decode(HttpObjectAggregator.java:89)〜[netty-all-4.0.42.Final.jar:4.0.42.Final]     at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)[netty-all-4.0.42.Final.jar:4.0.42.Final]     at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:367)[netty-all-4.0.42.Final.jar:4.0.42.Final]

 private DesiredCapabilities getDesiredCapabilitiesForSeleniumProxy() {
        DesiredCapabilities capabilities = DesiredCapabilities.chrome();    
        server = new BrowserMobProxyServer();
        server.setTrustAllServers(true);     
        server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
        server.start();
        server.addResponseFilter((response, content, info) -> {

            if (info.getOriginalUrl().endsWith("imports")) {
                try {
                    Id = parseJsonData(content.getTextContents());
                    JobId = getExternalJobId(content.getTextContents());
                } catch (JSONException e) {
                }
              }
        });
        Proxy proxy = ClientUtil.createSeleniumProxy(server);
        capabilities.setCapability(CapabilityType.PROXY, proxy);
        return capabilities;
    }

当我谷歌时,我得到了以下代码。我如何在我的代码中添加/使用。请帮忙

server.addFirstHttpFilterFactory(new RequestFilterAdapter.FilterSource(filter, 16777216));

0 个答案:

没有答案