I am trying to figure out how to use Browsermob, Selenium 4 and get the HAR for a URL programatically. Not sure if anyone can share current way to do this, but all the references I find do not seem to compile. Like:
-
- Server server = new Server(@"C:\temp\browsermob-proxy-2.1.4\bin\BrowserMobProxybinbrowsermob-proxy.bat");
- server.Start();
- Thread.Sleep(1000);
-
- Client client = server.CreateProxy();
- client.NewHar("assertselenium");
-
- var chromeOptions = new ChromeOptions();
- var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy, SslProxy = client.SeleniumProxy };
- chromeOptions.Proxy = seleniumProxy;
- var dr = new ChromeDriver(chromeOptions);
-
- dr.Navigate().GoToUrl("http://www.google.com");
- dr.FindElementByClassName("gb_e").Click();
-
- Thread.Sleep(3500);
- dr.Navigate().Refresh();
-
-
- HarResult harData = client.GetHar();
- Log log = harData.Log;
- Entry[] entries = log.Entries;
-
- foreach (var e in entries)
- {
- Request request = e.Request;
- Response response = e.Response;
- var url = request.Url;
- var time = e.Time;
- var status = response.Status;
- var testStr = "Url: " + url + " - Time: " + time + " Response: " + status;
- }
-
- dr.Quit();
- client.Close();
- server.Stop();
The Server and Client errors that the Namespace could not be found. Tried a number of paths but things like server.Stop() aren't found even if I can find an assembly just to get server.Start() to "look" OK. Though still think it's the wrong assembly.
Get the same for just HarResult, Log, Entry. Log and Entry I in theory can get to show OK with Grpc but not sure that's really the right reference to use.
Thoughts?