I am trying to setup BrowserMobProxy to capture performance data. However im not having much success at the moment. Most if not all of the documentation i can find seems to use the now deprecated ProxyServer. And the documentation on the BrowserMobProxy git does not provide any complete examples(unless im missing something).
So at the moment i have the proxy server up and running and also have created a har. But at the end of the test suite there is not much content in the file.
{"log":{"version":"1.2","creator":{"name":"BrowserMob Proxy","version":"2.1.0-beta-1-littleproxy","comment":""},"pages":[{"id":"pageName","startedDateTime":"2015-07-08T16:43:57.838+01:00","title":"pageName","pageTimings":{"comment":""},"comment":""}],"entries":[],"comment":""}}
Here is the proxy setup i currently have:
Run before each test suite in @BeforeSuite:
BrowserMobProxy server = new BrowserMobProxyServer();
server.start(0);
Proxy proxy = new Proxy();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
driver = new FirefoxDriver(capabilities);
server.newHar();
And then after the tests have finished in @AfterSuite
String timestamp = Long.toString(System.currentTimeMillis()/1000L);
String strFilePath = timestamp+ ".har";
Har har = server.getHar();
FileOutputStream fos = new FileOutputStream(strFilePath);
har.writeTo(fos);
server.stop();
driver.quit();
Can anybody fill me in on where i need to go from here? Or point me in the right direction?
Figure it out for anybody else that stumbles across this. The problem was that the site im working on uses ssl. So i needed to setSSLProxy for the selenium proxy configuration to "trustAllSSLCertificates". So now im left with this as my browsermob proxy config:
server = new BrowserMobProxyServer();
server.start(0);
Proxy proxy = ClientUtil.createSeleniumProxy(server);
proxy.setSslProxy("trustAllSSLCertificates");