Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access values in the Chrome Devtools network tab using Python?

Is there a way to access values from the Network tab? Like for example everything under the Name column? Im using Selenium and am interested in monitoring the Network tab. Thanks

like image 223
West Avatar asked Sep 09 '26 05:09

West


1 Answers

In C# I'm using the following way:

Initializing driver:

            var perfLogPrefs = new ChromePerformanceLoggingPreferences();
        perfLogPrefs.AddTracingCategories(new string[] { "devtools.network", "devtools.timeline" });
        options.PerformanceLoggingPreferences = perfLogPrefs;
        options.AddAdditionalCapability(CapabilityType.EnableProfiling, true, true);
        options.SetLoggingPreference("performance", LogLevel.All);


        driver = new ChromeDriver(
            ConfigManager.ChromeDriverPath, options);
        ScenarioDefinitions.PathToGoogleCustomProfile = string.Empty;

Getting data from the logs:

var data = driver.Manage().Logs.GetLog("performance");

As a result - you would get a huge amount of json files with all the data. Translating this code from C# to Python, along with parsing the data you need from json shouldn't be that hard. Hope it helps.

Best Regards, Vitali.

like image 148
Vital Avatar answered Sep 11 '26 17:09

Vital



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!