Unable to get the network traces and the har file is empty.

101 views
Skip to first unread message

Sridhar Rajendran

unread,
Apr 15, 2020, 11:55:13 AM4/15/20
to BrowserMob Proxy
It is creating the har file, but it didn't capture any network traces. Could you please someone help on this?

Code:

package makemyhar;


import java.io.File;

import java.io.IOException;

import java.net.Inet4Address;

import java.net.UnknownHostException;


import org.openqa.selenium.Proxy;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.chrome.ChromeOptions;

import org.openqa.selenium.remote.CapabilityType;

import org.openqa.selenium.remote.DesiredCapabilities;


import net.lightbody.bmp.BrowserMobProxyServer;

import net.lightbody.bmp.client.ClientUtil;

import net.lightbody.bmp.core.har.Har;

import net.lightbody.bmp.proxy.CaptureType;


public class test {

public static WebDriver driver;

public static BrowserMobProxyServer proxy;


public static void main(String[] args) {


System.setProperty("webdriver.chrome.driver", "/Users/srajendran/Desktop/chromedriver");

proxy = new BrowserMobProxyServer();

proxy.setTrustAllServers(true);

proxy.start();


Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

try {

String hostIp = Inet4Address.getLocalHost().getHostAddress();

System.out.println();

seleniumProxy.setHttpProxy(hostIp + ":" + proxy.getPort());

seleniumProxy.setSslProxy(hostIp + ":" + proxy.getPort());

} catch (UnknownHostException e) {

e.printStackTrace();

}


DesiredCapabilities seleniumCapabilities = DesiredCapabilities.chrome();


seleniumCapabilities.setCapability(CapabilityType.PROXY, seleniumProxy);

ChromeOptions options = new ChromeOptions();

driver = new ChromeDriver(options);


proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);


try {


proxy.newHar("swtestacademy");


driver.get("http://www.google.com");

try {

Thread.sleep(10000);

} catch (InterruptedException e) {

e.printStackTrace();

}


Har har = proxy.getHar();

System.out.println(har);


File harFile = new File("academy.har");

har.writeTo(harFile);


} catch (IOException ioe) {

ioe.printStackTrace();

}

driver.quit();

proxy.stop();

}

}



Console Error

INFO  DefaultHttpProxyServer: Starting proxy at address: 0.0.0.0/0.0.0.0:0

INFO  DefaultHttpProxyServer: Proxy listening with TCP transport

INFO  DefaultHttpProxyServer: Proxy started at address: /0:0:0:0:0:0:0:0:61774


Starting ChromeDriver 2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85) on port 25846

Only local connections are allowed.

Apr 15, 2020 9:22:35 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Detected dialect: OSS

[1586965966.602][SEVERE]: Unable to receive message from renderer

Exception in thread "main" org.openqa.selenium.WebDriverException: disconnected: Unable to receive message from renderer

  (Session info: chrome=81.0.4044.92)

  (Driver info: chromedriver=2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85),platform=Mac OS X 10.14.6 x86_64) (WARNING: The server did not provide any stacktrace information)

Command duration or timeout: 11.07 seconds

Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

System info: host: '671212959NB001.local', ip: 'fe80:0:0:0:10cd:4748:2322:66ef%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '1.8.0_231'

Driver info: org.openqa.selenium.chrome.ChromeDriver

Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.37.544337 (8c0344a12e552148c185f7d5117db1f28d6c9e85), userDataDir=/var/folders/jd/gg0jfhxs0hz4sgwszdxb2zx85nxw25/T/.org.chromium.Chromium.7Bnmw7}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=81.0.4044.92, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=false, acceptInsecureCerts=false, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]

Session ID: d5e815355553accbf1f48ad231e25d0e

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:215)

at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:167)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:671)

at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:364)

at makemyhar.test.main(test.java:57)

Reply all
Reply to author
Forward
0 new messages