How get javascript log using Selenium on NUnit test?

前提是你 提交于 2019-12-11 07:25:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!