问题
I'm trying to retrive Javascript console logs from NUnit test on Visual studio using Selenium ChromeDriver but i get a null value on Logs.
I have tried the code below but it will give a Null point reference on "driver.Manage().Logs.GetLog(LogType.Browser);". I'm using last version of ChromeDriver v75.
options.SetLoggingPreference(LogType.Browser, LogLevel.Warning);
var driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("http://stackoverflow.com");
var entries = driver.Manage().Logs.GetLog(LogType.Browser);
foreach (var entry in entries) {
Console.WriteLine(entry.ToString());
}
I think that there is an version problem between the Chrome version and the ChromeDriver on Visual studio.
回答1:
For the moment for workaround i downgrade he ChromeDriver to version 72 an now it's working correctly.
来源:https://stackoverflow.com/questions/56654489/how-get-javascript-log-using-selenium-on-nunit-test