Har file containing empty data

797 views
Skip to first unread message

Mamta Garg

unread,
Feb 2, 2017, 1:39:52 PM2/2/17
to BrowserMob Proxy
Hi

I am facing some issues in collecting har data with the BrowserMob Proxy.
I cloned the latest BrowserMob Proxy and running the code as exactly written in Readme.md. However my har file is empty. Please help me in this regard

Details :- Latest Selenium + Browser Mob + Driver (on Mac)

Har Output :- {"log":{"version":"1.2","creator":{"name":"BrowserMob Proxy","version":"2.1.4","comment":""},"pages":[{"id":"yahoo.com","startedDateTime":"2017-02-02T18:16:00.918Z","title":"yahoo.com","pageTimings":{"comment":""},"comment":""}],"entries":[],"comment":""}}

Code :-
 // start the proxy
    BrowserMobProxy proxy = new BrowserMobProxyServer();
    proxy.start(0);

    // get the Selenium proxy object
    Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);

    // configure it as a desired capability
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);

    // start the browser up
    WebDriver driver = new FirefoxDriver(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");
    driver.findElement(By.id("UHSearchWeb")).click();

    // get the HAR data
    Har har = proxy.getHar();



HAR object trace image :-


Thanks,
Tarun
Auto Generated Inline Image 1

Jayakrishnan Nair

unread,
Feb 19, 2017, 10:32:05 PM2/19/17
to BrowserMob Proxy
Set the http,ssl,ftp port of the browser after start browsermob proxy.

           profile.setPreference("network.proxy.type",1);
   profile.setPreference("network.proxy.ftp",localhost);
   profile.setPreference("network.proxy.http",localhost);
   profile.setPreference("network.proxy.socks",localhost);
   profile.setPreference("network.proxy.ssl",localhost);
   profile.setPreference("network.proxy.ftp_port",8002);
   profile.setPreference("network.proxy.http_port",8002);
   profile.setPreference("network.proxy.socks_port",8002);
   profile.setPreference("network.proxy.ssl_port",8002);
Enter code here...


Reply all
Reply to author
Forward
0 new messages