3

In version 74.0.3729.6 of the Selenium.WebDriver.ChromeDriver I am able to run the following code without problem:

foreach (var logItem in driverInstance.Manage().Logs.GetLog(LogType.Browser).ToList())
{
    NLogLogger.Debug(logItem.Message);
}

But from version 75.0.3770.90

System.NullReferenceException: 'Object reference not set to an instance of an object.'

Within the latest release notes I found some mention of logging changing but no clear indication of what has changed or might be causing this problem:

  • Resolved issue 2947: No W3C compliant endpoints for retrieving logs [Pri-2]
  • Resolved issue 2803: Capability name loggingPrefs is not spec compliant [Pri-2]

https://chromedriver.storage.googleapis.com/75.0.3770.90/notes.txt

Ideally I would not like to remove this code as my ability to acquire logs from the browser side is a requirement but I would also not like to be locked down to version 74 of the Selenium Chrome Driver as this will obviously over time become a bigger and bigger problem, so I am wondering whether someone could suggest a different way of accessing these logs dynamically?

BernardV
  • 640
  • 10
  • 28
  • Some more information on this: https://github.com/SeleniumHQ/selenium/issues/7342 – BernardV Jul 09 '19 at 13:22
  • So glad someone else ran into this problem and not just me. Wish the problem didn't exist at all. Thanks for posting the question. Fairly critical feature imho. Would give this question 5 points up if I could. – Fractal Jul 24 '19 at 18:24

2 Answers2

2

driver.Manage().Logs.GetLog(LogType.Browser) no longer working in Chromedriver version 75.0.3770

I ran into the same issue, unfortunately it is not going to work in w3c mode for the current version of Selenium.

Fieldfare
  • 167
  • 1
  • 8
0

Not sure about C# bindings but for Java changing loggingPrefs to goog:loggingPrefs helped me, I've found an answer here: https://stackoverflow.com/a/56536604/10824437

  • Thanks Artem, I have also stumbled upon this, but I am not sure as of yet how to implement this method in C# as they do not use `setCapability` in the same way, an example of how my setup looks is more similar to: `chromeOptions.SetLoggingPreference(LogType.Browser, OpenQA.Selenium.LogLevel.Debug); chromeOptions.SetLoggingPreference(LogType.Driver, OpenQA.Selenium.LogLevel.Severe); ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);` – BernardV Jul 09 '19 at 13:11
  • @BernardV, you could try to join to Slack and ask selenium developers/users there: https://www.seleniumhq.org/slack/ . It's the same channel as their irc: #selenium at Freenode – Artem Krosheninnikov Jul 09 '19 at 21:46