Trying to use PhantomJS(com.codeborne:phantomjsdriver:1.2.1) for some headless browser testing along with BrowserMob Proxy(browsermob-proxy-2.0-beta-9) to capture HAR files and Javascript execution.
It works for urls with https(eg. https://www.google.com) and I get the HAR.
However for http(eg. http://www.google.com) I get the following error in the BrowserMob logs
INFO 02/02 22:45:03 n.l.b.p.j.h.HttpSer~ - Version Jetty/5.1.x
INFO 02/02 22:45:03 n.l.b.p.j.u.Contain~ - Started HttpContext[/,/]
...
INFO 02/02 22:46:29 n.l.b.p.h.BrowserMo~ - java.net.UnknownHostException: www.google.com when requesting http://www.google.com/
INFO 02/02 22:46:54 n.l.b.p.j.u.Threade~ - Stopping Acceptor ServerSocket[addr=/0.0.0.0,localport=13000]
...
Following is how I setup PhantomJS
public RemoteWebDriver getDriverInstance() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
//code to get Proxy is below
capabilities.setCapability(CapabilityType.PROXY, getProxyObject());
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "./bin/phantomjs");
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=no", "--ssl-protocol=any", "--ignore-ssl-errors=yes"});
WebDriver webDriver = new PhantomJSDriver(capabilities);
return (RemoteWebDriver) webDriver;
}
public Proxy getProxyObject() {
Proxy proxy = new Proxy();
//publicIp is localhost for testing purposes.
String proxyLocation = this.getPublicIp() + ":" + this.getBrowserMobProxyPort();
proxy.setHttpProxy(proxyLocation);
proxy.setFtpProxy(proxyLocation);
proxy.setSslProxy(proxyLocation);
return proxy;
}
Still looking for a solution.
Is it normal to expect such messages from BrowserMob?
I, most probably have not setup something correctly or missed a part. Would be awesome if anyone who has faced this issue, help me out or point me to a solution. I have done some searching but not found a solution that resolves this.
Also if there is additional information needed, please let me know.