Hi,
Did you implemented and read the documentation of BrowserMobProxy?
I hope you already tried this code :
public void setUp(String pageRef, String url){
proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.start();
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-notifications");
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setAcceptInsecureCerts(true);
System.setProperty("webdriver.chrome.driver", driverPath);
driver = new ChromeDriver(capabilities);
JavascriptExecutor js = (JavascriptExecutor) driver;
proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT);
proxy.newHar(pageRef);
driver.get(url);
driver.manage().timeouts().pageLoadTimeout(15, TimeUnit.SECONDS);
}
public void tearDown(String FileName) {
Har har = proxy.getHar();
File harFile = new File(FileName);
try {
har.writeTo(harFile);
} catch (IOException e) {
System.out.println("Could not find file " + FileName);
}
if (driver != null) {
proxy.stop();
driver.quit();
}
}