我正在尝试使用BMP的RequestFilter和ResponseFilter获取响应和请求。然而,当网页加载时,在控制台中没有任何打印输出。
其他所有东西似乎都能工作。也许BMP没有监视GeckoDriver?
我正在使用Firefox 50.0、BrowserMobProxy 2.1.2、Selenium 3.0.1和GeckoDriver 0.11.1
下面是测试代码,请有人帮帮我吗?
非常感谢!
其他所有东西似乎都能工作。也许BMP没有监视GeckoDriver?
我正在使用Firefox 50.0、BrowserMobProxy 2.1.2、Selenium 3.0.1和GeckoDriver 0.11.1
下面是测试代码,请有人帮帮我吗?
非常感谢!
BrowserMobProxy server = new BrowserMobProxyServer();
server.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
server.start();
int port = server.getPort();
server.addRequestFilter((request, content, info) -> {
String q = URLDecoder.decode(info.getOriginalUrl(), "UTF-8");
System.out.println("Request: "+q);
return null;
});
server.addResponseFilter((response, content, info) -> {
String type = response.headers().get("Content-Type");
System.out.println("Response: "+info.getOriginalRequest());
System.out.println(type);
});
Proxy proxy = ClientUtil.createSeleniumProxy(server);
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
capabilities.setCapability("marionette", true);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT, true);
FirefoxProfile fp = new FirefoxProfile();
capabilities.setCapability(FirefoxDriver.PROFILE, fp);
String gecko = "d:/Programming/java/geckodriver.exe";
System.setProperty("webdriver.gecko.driver", gecko);
driver = new FirefoxDriver(capabilities);
driver.get("https://google.com");;