我正在尝试使用BrowserMobProxy拦截Webdriver发出的请求。
但是以下代码无法正常工作。无法打开网站google.com。
它说“ Internet Explorer无法打开该站点”
proxyServer = new ProxyServer(9101);
proxyServer.start();
proxyServer.setCaptureHeaders(true);
proxyServer.setCaptureContent(true);
proxyServer.addRequestInterceptor(new RequestInterceptor() {
@Override
public void process(BrowserMobHttpRequest request, Har har) {
System.out.println("From Process method");
}
});
seleniumProxy = proxy.seleniumProxy();
seleniumProxy.setHttpProxy("localhost:9101");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
capabilities.setCapability("ie.setProxyByServer", true);
File file = new File("C:\\path\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver(capabilities);
driver.get("www.google.com");
尝试从webdrviver访问google.com时出现以下错误
From Process method Nov 09, 2014 2:07:58 AM net.lightbody.bmp.proxy.util.Log info INFO: java.net.UnknownHostException: www.google.com when requesting http://www.google.com/
Browsermob使用xbill DNS代替常规的Java /本地DNS解析,这可能不适用于您的VPN。最新的browsermob快照使您可以通过将system属性设置bmp.allowNativeDnsFallback
为true来启用本机DNS回退:
System.setProperty("bmp.allowNativeDnsFallback", "true");
proxyServer = new ProxyServer(9101);
proxyServer.start();
您可以在browsermob github页面上获取最新快照。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句