Skip to content

Commit 10d5f8c

Browse files
authored
[dotnet] Support GetLog command by Remote Web Driver (#14549)
* [dotnet] Support GetLog command by Remote Web Driver * Don't swallow not implemented exception, user should see it
1 parent 1216ed9 commit 10d5f8c

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

dotnet/src/webdriver/Logs.cs

+11-17
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,23 @@ public ReadOnlyCollection<string> AvailableLogTypes
7676
public ReadOnlyCollection<LogEntry> GetLog(string logKind)
7777
{
7878
List<LogEntry> entries = new List<LogEntry>();
79-
try
80-
{
81-
Dictionary<string, object> parameters = new Dictionary<string, object>();
82-
parameters.Add("type", logKind);
83-
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);
8479

85-
object[] responseValue = commandResponse.Value as object[];
86-
if (responseValue != null)
80+
Dictionary<string, object> parameters = new Dictionary<string, object>();
81+
parameters.Add("type", logKind);
82+
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);
83+
84+
object[] responseValue = commandResponse.Value as object[];
85+
if (responseValue != null)
86+
{
87+
foreach (object rawEntry in responseValue)
8788
{
88-
foreach (object rawEntry in responseValue)
89+
Dictionary<string, object> entryDictionary = rawEntry as Dictionary<string, object>;
90+
if (entryDictionary != null)
8991
{
90-
Dictionary<string, object> entryDictionary = rawEntry as Dictionary<string, object>;
91-
if (entryDictionary != null)
92-
{
93-
entries.Add(LogEntry.FromDictionary(entryDictionary));
94-
}
92+
entries.Add(LogEntry.FromDictionary(entryDictionary));
9593
}
9694
}
9795
}
98-
catch (NotImplementedException)
99-
{
100-
// Swallow for backwards compatibility
101-
}
10296

10397
return entries.AsReadOnly();
10498
}

dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ protected override void InitializeCommandDictionary()
133133
// local-end implementation of WebDriver.
134134
this.TryAddCommand(DriverCommand.IsElementDisplayed, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/element/{id}/displayed"));
135135
this.TryAddCommand(DriverCommand.ElementEquals, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/element/{id}/equals/{other}"));
136+
this.TryAddCommand(DriverCommand.GetLog, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/log"));
137+
this.TryAddCommand(DriverCommand.GetAvailableLogTypes, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/log/types"));
136138
this.TryAddCommand(DriverCommand.UploadFile, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/file"));
137139
this.TryAddCommand(DriverCommand.GetDownloadableFiles, new HttpCommandInfo(HttpCommandInfo.GetCommand, "/session/{sessionId}/se/files"));
138140
this.TryAddCommand(DriverCommand.DownloadFile, new HttpCommandInfo(HttpCommandInfo.PostCommand, "/session/{sessionId}/se/files"));

0 commit comments

Comments
 (0)