4

I'm trying to access the network tab information from a chrome page that was launched with ChromeDriver in C#.

enter image description here

I would like total data transferred and page load time at the least...

I've been messing around with setting different ChromeOptions and DesiredCapabilities, much to no success. The only thing I've gotten to work so far is executing a script and converting the results to a long.

Convert.ToInt64(((IJavaScriptExecutor)ChromeDriver).ExecuteScript("return window.performance.timing.navigationStart"));

however, I'd like to not do it this way, if that's possible... Thanks in advance!

Code Rocker
  • 500
  • 4
  • 15
Brian Corbin
  • 267
  • 1
  • 12

1 Answers1

1

In that case that other people are seeing this in the future I will share some information. Because I have currently also have problems with devtools.

There is an official guide from Selenium if you are using an 4.0 alpha how to interact with dev tools.

I will share the snipet here I'm currently using.

IDevTools devTools = driver as IDevTools;
DevToolsSession session = devTools.CreateDevToolsSession();
session.Network.ResponseReceived += ResponseReceivedHandler;
session.Network.Enable(new EnableCommandSettings());
public void ResponseReceivedHandler(object sender, ResponseReceivedEventArgs e)
{
   Debug.WriteLine($"Status: { e.Response.Status } : {e.Response.StatusText} | File: 
   { e.Response.MimeType } | Url: { e.Response.Url } ");
}

I tried a lot to figure out how I can get the information I want to. Maybe my own question is answered until you see this, I shared everything I have tried out.

Also this guide can help you to get started.

Schmebi
  • 355
  • 2
  • 16