简体   繁体   中英

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

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.

I did it in Python using Selenium

https://stackoverflow.com/a/68363046/8491363

The key is setting the performance log.

From Selenium 4.0 onward, the library officially support accessing Chrome devtool info so you can also use that instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM