当我在 chrome 浏览器(硒)上运行测试时,我最近开始看到以下问题
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] 在 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] 在 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));