selenium: C# unable to enable performance logging for ChromeDriver

Chrome:Version 75.0.3770.100 ChromeDriver:75.0.3770.90 Selenium:3.141.0

I’m getting the error ``` OpenQA.Selenium.WebDriverException: ‘invalid argument: entry 0 of ‘firstMatch’ is invalid from invalid argument: perfLoggingPrefs specified, but performance logging was not enabled’

If the work around is to use LoggingPreference, can someone please tell me how to reference it since it does not seem to be in the 3.141.0 dll. Also, I think this might relate to the changes to 75.0.3770.8 Renamed capability loggingPrefs to goog:loggingPrefs, as required by W3C standard

public Driver(ChromeDriverModel chromeDriverModel)
        {
            ChromeOptions chromeOptions = new ChromeOptions();
            enablePerformanceMonitor = chromeDriverModel.enablePerformanceMonitoring;
            if (enablePerformanceMonitor)
                chromeOptions = _ChromePerformanceOptions();

            if (!string.IsNullOrWhiteSpace(chromeDriverModel.ChromeDriverLocation))
            {
                if (enablePerformanceMonitor)
                    _webDriver = new ChromeDriver(chromeDriverModel.ChromeDriverLocation, chromeOptions);
                else
                    _webDriver = new ChromeDriver(chromeDriverModel.ChromeDriverLocation);
            }
            else
            {
                if (enablePerformanceMonitor)
                    _webDriver = new ChromeDriver(chromeOptions);
                else
                    _webDriver = new ChromeDriver();
            }
        }


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

Sorry if repost, not sure which is the official spot. 

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 25 (5 by maintainers)

Commits related to this issue

Most upvoted comments

JFYI upgrading to Chrome-76/Chromedriver-76 did not help. See the issue referenced #7390

Hi All,

With Selenium WebDriver (v4.0.0-alpha04) and Selenium.Chrome.WebDriver (v79.0.0) and using the following code, I am able to retrieve the Chrome performance logs.

ChromeOptions options = new ChromeOptions();

//Following helps in setting the logging preference options.SetLoggingPreference(“performance”, LogLevel.All);

//Based on your need you can change the following options options.AddUserProfilePreference(“intl.accept_languages”, “en-US”); options.AddUserProfilePreference(“disable-popup-blocking”, “true”); options.AddArgument(“test-type”); options.AddArgument(“–disable-gpu”); options.AddArgument(“no-sandbox”); options.AddArgument(“start-maximized”); options.LeaveBrowserRunning = true;

//Creating Chrome driver instance IWebDriver driver = new ChromeDriver(options);

//Extracting the performance logs var logs = driver.Manage().Logs.GetLog(“performance”); for (int i = 0; i < logs.Count; i++) { Console.WriteLine(logs[i].Message); }

Hope this helps.

Referenced issue #7390 was closed but issue seems to be still not fixed. Any update on this?

Hi All, With Selenium WebDriver (v4.0.0-alpha04) and Selenium.Chrome.WebDriver (v79.0.0) and using the following code, I am able to retrieve the Chrome performance logs. ChromeOptions options = new ChromeOptions(); //Following helps in setting the logging preference options.SetLoggingPreference(“performance”, LogLevel.All); //Based on your need you can change the following options options.AddUserProfilePreference(“intl.accept_languages”, “en-US”); options.AddUserProfilePreference(“disable-popup-blocking”, “true”); options.AddArgument(“test-type”); options.AddArgument(“–disable-gpu”); options.AddArgument(“no-sandbox”); options.AddArgument(“start-maximized”); options.LeaveBrowserRunning = true; //Creating Chrome driver instance IWebDriver driver = new ChromeDriver(options); //Extracting the performance logs var logs = driver.Manage().Logs.GetLog(“performance”); for (int i = 0; i < logs.Count; i++) { Console.WriteLine(logs[i].Message); } Hope this helps.

未将对象引用设置到对象的实例。 the logs is null

ChromeDriver 81.0.4044.69

so how can i get the response header?

thankyou

I suggest you check the webdriver version (4.0.0-alpha05), you can find it in NuGet (checked ‘Include prerelease’)

Hi All,

With Selenium WebDriver (v4.0.0-alpha04) and Selenium.Chrome.WebDriver (v79.0.0) and using the following code, I am able to retrieve the Chrome performance logs.

ChromeOptions options = new ChromeOptions();

//Following helps in setting the logging preference options.SetLoggingPreference(“performance”, LogLevel.All);

//Based on your need you can change the following options options.AddUserProfilePreference(“intl.accept_languages”, “en-US”); options.AddUserProfilePreference(“disable-popup-blocking”, “true”); options.AddArgument(“test-type”); options.AddArgument(“–disable-gpu”); options.AddArgument(“no-sandbox”); options.AddArgument(“start-maximized”); options.LeaveBrowserRunning = true;

//Creating Chrome driver instance IWebDriver driver = new ChromeDriver(options);

//Extracting the performance logs var logs = driver.Manage().Logs.GetLog(“performance”); for (int i = 0; i < logs.Count; i++) { Console.WriteLine(logs[i].Message); }

Hope this helps.

未将对象引用设置到对象的实例。 the logs is null

ChromeDriver 81.0.4044.69

so how can i get the response header?

thankyou