To configure and get log entries using Selenium / Chrome / C #:
ChromeOptions options = new ChromeOptions(); 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()); }
And with Firefox:
FirefoxOptions options = new FirefoxOptions(); options.SetLoggingPreference(LogType.Browser, LogLevel.Warning); var driver = new FirefoxDriver(options); driver.Navigate().GoToUrl("http://stackoverflow.com"); var entries = driver.Manage().Logs.GetLog(LogType.Browser); foreach (var entry in entries) { Console.WriteLine(entry.ToString()); }
source share