Last active
November 18, 2016 15:52
-
-
Save scrooby/99cc24b58bba78c79f2471d59738fa7d to your computer and use it in GitHub Desktop.
Retrieve the browser logs using Selenium and write them out to the console after each scenario
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AfterScenario(Order = 0)] | |
public void ErrorHandling() | |
{ | |
WriteBrowserLogs(); | |
} | |
private void WriteBrowserLogs() | |
{ | |
var driverType = SeleniumController.Instance.DriverType; | |
if (driverType != SeleniumDriverType.Chrome) | |
{ | |
return; | |
} | |
var browserLogs = seleniumContext.Selenium.Manage().Logs.GetLog(LogType.Browser); | |
if (browserLogs.Any()) | |
{ | |
Console.WriteLine(); | |
Console.WriteLine("Browser logs:"); | |
foreach (var log in browserLogs) | |
{ | |
Console.WriteLine(log.ToString()); | |
} | |
} | |
else | |
{ | |
Console.WriteLine(); | |
Console.WriteLine("No browser logs found"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment