Skip to content

Commit

Permalink
[dotnet] Support GetLog command by Remote Web Driver (#14549)
Browse files Browse the repository at this point in the history
* [dotnet] Support GetLog command by Remote Web Driver

* Don't swallow not implemented exception, user should see it
  • Loading branch information
nvborisenko authored Oct 3, 2024
1 parent 1216ed9 commit 10d5f8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
28 changes: 11 additions & 17 deletions dotnet/src/webdriver/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,29 +76,23 @@ public ReadOnlyCollection<string> AvailableLogTypes
public ReadOnlyCollection<LogEntry> GetLog(string logKind)
{
List<LogEntry> entries = new List<LogEntry>();
try
{
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);

object[] responseValue = commandResponse.Value as object[];
if (responseValue != null)
Dictionary<string, object> parameters = new Dictionary<string, object>();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);

object[] responseValue = commandResponse.Value as object[];
if (responseValue != null)
{
foreach (object rawEntry in responseValue)
{
foreach (object rawEntry in responseValue)
Dictionary<string, object> entryDictionary = rawEntry as Dictionary<string, object>;
if (entryDictionary != null)
{
Dictionary<string, object> entryDictionary = rawEntry as Dictionary<string, object>;
if (entryDictionary != null)
{
entries.Add(LogEntry.FromDictionary(entryDictionary));
}
entries.Add(LogEntry.FromDictionary(entryDictionary));
}
}
}
catch (NotImplementedException)
{
// Swallow for backwards compatibility
}

return entries.AsReadOnly();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ protected override void InitializeCommandDictionary()
// local-end implementation of WebDriver.
this.TryAddCommand(DriverCommand.IsElementDisplayed, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/element/{id}/displayed"));
this.TryAddCommand(DriverCommand.ElementEquals, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/element/{id}/equals/{other}"));
this.TryAddCommand(DriverCommand.GetLog, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/log"));
this.TryAddCommand(DriverCommand.GetAvailableLogTypes, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/log/types"));
this.TryAddCommand(DriverCommand.UploadFile, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/file"));
this.TryAddCommand(DriverCommand.GetDownloadableFiles, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/files"));
this.TryAddCommand(DriverCommand.DownloadFile, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/files"));
Expand Down

0 comments on commit 10d5f8c

Please sign in to comment.