BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.start(9095);
// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
// seleniumProxy.setHttpProxy("localhost:"+ proxy.getPort());
// seleniumProxy.setSslProxy("localhost:"+ proxy.getPort());
// configure it as a desired capability
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
// start the browser up
System.setProperty("webdriver.chrome.driver", "/Users/212570773/Downloads/chromedriver");
WebDriver driver = new ChromeDriver(capabilities);
// enable more detailed HAR capture, if desired (see CaptureType for the complete list)
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
// create a new HAR with the label "yahoo.com"
proxy.newHar("yahoo.com");
// open yahoo.com
driver.get("http://yahoo.com");
// get the HAR data
Har har = proxy.getHar();
File harFile = new File("/Users/212570773/Downloads/ken.har");
har.writeTo(harFile);
// driver.quit();