Provides a mechanism for examining logs for the driver during the test.
| 25 | /// Provides a mechanism for examining logs for the driver during the test. |
| 26 | /// </summary> |
| 27 | public class Logs : ILogs |
| 28 | { |
| 29 | private readonly WebDriver driver; |
| 30 | |
| 31 | /// <summary> |
| 32 | /// Initializes a new instance of the <see cref="Logs"/> class. |
| 33 | /// </summary> |
| 34 | /// <param name="driver">Instance of the driver currently in use</param> |
| 35 | /// <exception cref="ArgumentNullException">If <paramref name="driver"/> is <see langword="null"/>.</exception> |
| 36 | public Logs(WebDriver driver) |
| 37 | { |
| 38 | ArgumentNullException.ThrowIfNull(driver); |
| 39 | this.driver = driver; |
| 40 | } |
| 41 | |
| 42 | /// <summary> |
| 43 | /// Gets the list of available log types for this driver. |
| 44 | /// </summary> |
| 45 | public ReadOnlyCollection<string> AvailableLogTypes |
| 46 | { |
| 47 | get |
| 48 | { |
| 49 | List<string> availableLogTypes = new List<string>(); |
| 50 | try |
| 51 | { |
| 52 | Response commandResponse = this.driver.Execute(DriverCommand.GetAvailableLogTypes, null); |
| 53 | if (commandResponse.Value is object[] responseValue) |
| 54 | { |
| 55 | foreach (object logKind in responseValue) |
| 56 | { |
| 57 | availableLogTypes.Add(logKind.ToString()!); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | catch (NotImplementedException) |
| 62 | { |
| 63 | // Swallow for backwards compatibility |
| 64 | } |
| 65 | |
| 66 | return availableLogTypes.AsReadOnly(); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /// <summary> |
| 71 | /// Gets the set of <see cref="LogEntry"/> objects for a specified log. |
| 72 | /// </summary> |
| 73 | /// <param name="logKind">The log for which to retrieve the log entries. |
| 74 | /// Log types can be found in the <see cref="LogType"/> class.</param> |
| 75 | /// <returns>The list of <see cref="LogEntry"/> objects for the specified log.</returns> |
| 76 | /// <exception cref="ArgumentNullException">If <paramref name="logKind"/> is <see langword="null"/>.</exception> |
| 77 | public ReadOnlyCollection<LogEntry> GetLog(string logKind) |
| 78 | { |
| 79 | ArgumentNullException.ThrowIfNull(logKind); |
| 80 | |
| 81 | List<LogEntry> entries = new List<LogEntry>(); |
| 82 | |
| 83 | Dictionary<string, object?> parameters = new Dictionary<string, object?>(); |
| 84 | parameters.Add("type", logKind); |
nothing calls this directly
no test coverage detected