要使用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());}
对于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());}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)