0

I am working with capture traffic from Chrome browser by BrowserMob. I download BrowserMob app with .bat files. I also work with Selenium Webdriver. I add .cs files to Browser project from Github. What I want is get network traffic.

My code is:

using (IWebDriver driver = new ChromeDriver())
            {



var server = new Server(@"C:\Users\Barp\Downloads\browsermob-proxy-2.1.4-bin\browsermob-proxy-2.1.4\bin\browsermob-proxy.bat");
server.Start();
Thread.Sleep(1000);
Client client = server.CreateProxy();

 client.NewHar("google");
 var chromeOptions = new ChromeOptions();
 var seleniumProxy = new Proxy1 { HttpProxy = client.SeleniumProxy };
 chromeOptions.Proxy = seleniumProxy;
 Thread.Sleep(1500);
 var dr = new ChromeDriver(chromeOptions);
 dr.Navigate().GoToUrl("http://www.google.co.uk");
 var harData = client.GetHar();



HarResult harDat = client.GetHar();

WebdriverTestGUI2.BrowserMob.Log log = harDat.Log;
WebdriverTestGUI2.BrowserMob.Entry[] entries = log.Entries;
foreach (var entry in entries)
{
      WebdriverTestGUI2.BrowserMob.Request request = entry.Request;
      var url = request.Url;
  var time = entry.Time;
  Console.WriteLine("Url: " + url + " - Time: " + time);
                }



      driver.Quit();
      client.Close();
      server.Stop()
}
}

Have you anything change in your .bat file or maybe in other BrowserMob files ?

CMD is opening, Start also works well, but I have got errors that appear in cmd:

Error FileManager (bmp.log) java.io.FileNotFound Exception bmp.log (Access is denied)

-Error Unable to inject fields into builder class for plugin type class org.apache.logging.log4j.core unable to create manager for bmp.log

-Error unable to invoke factory method in class class org.apache.logging.log4j.core.appender.FileAppender for element file java.lang.IllegalStateException: No factory method found

-Error NULL object return for file in appenders

-Error unable to locate appender "file " for logger config.

Barpe2
  • 39
  • 7
  • OK, access denied I have resolved. I should run as Administrator this BrowserMob. – Barpe2 Mar 03 '17 at 14:50
  • When BrowserMob is launching within your core app, how do you launch BrowserMob as Administrator within your app? – John May 27 '21 at 14:00

1 Answers1

0

Hey I had the same issue here

I changed the .Start process in Server.cs to start like so:

     _serverProcess = new Process
        {
            StartInfo = { FileName = _path,
                           UseShellExecute = true,
                           Verb = "runas"
                         }
        }

the UseShellExecute and Verb are key here, I also added app.manifest with:

requestedExecutionLevel  level="requireAdministrator" uiAccess="false"
Jeffrey LeCours
  • 1,213
  • 13
  • 21