0

I am not able to Fetch Network Logs using Browsermob Proxy when set Http proxy , it will just create a har file but i am not able to see any logs inside the file

Below is my Code :-

String strFilePath = "./PerformanceLogs/PerformanceLogs.har";
            String noProxy = "localhost, 127.0.0.1";

        LegacyProxyServer server = new BrowserMobProxyServer();
        server.start();
        server.setCaptureHeaders(true);
        server.setCaptureContent(true);
        Proxy proxy = server.seleniumProxy().setHttpProxy(PROXY)
                .setFtpProxy(PROXY)
                .setSslProxy(PROXY)
                .setNoProxy(noProxy);

         DesiredCapabilities capabilities = DesiredCapabilities.firefox();
         capabilities.setCapability(CapabilityType.PROXY, proxy);

         WebDriver driver = new FirefoxDriver(capabilities);

        server.newHar("NetworkLogs");
        driver.navigate().to("https://url-");

        driver.findElements(xpath="").click();

        pMonitor = new Prism_Selenium_Monitor_Tab(driver);
        pMonitor.prism_monitor_credentialDeploy(URL,excelfile[0], excelfile[4]);

        Har har = server.getHar();
        File harFile = new File(strFilePath);
        har.writeTo(harFile);
        server.stop();

can anyone please me in this? Thanks in advance

ArK
  • 18,824
  • 63
  • 101
  • 135
Sumanth N
  • 1
  • 1

1 Answers1

0
  1. For some reason you're starting LegacyProxy, try starting BrowserMobProxyServer, i.e.

    BrowserMobProxyServer server = new BrowserMobProxyServer();

  2. Default proxy type is HTTP, i.e. try to delete this part:

    .setNoProxy(noProxy);

  3. It's actually shouldn't be a problem, but in default case there is no need to name your HAR, i.e. this code is redundant:

    server.newHar("NetworkLogs");

you may just:

server.newHar();

Mikhail
  • 605
  • 4
  • 13