From 2c19127976a28d67ee8269e11b5a7931004f80f0 Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Tue, 1 Oct 2024 21:10:12 +0300 Subject: [PATCH 1/2] [dotnet] Support GetLog command by Remote Web Driver --- .../webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs b/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs index 384599ac6ef92..162add5ea0f45 100644 --- a/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs +++ b/dotnet/src/webdriver/Remote/W3CWireProtocolCommandInfoRepository.cs @@ -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")); From f1581aa26cfa87b0f0569596e7b694b74536367a Mon Sep 17 00:00:00 2001 From: Nikolay Borisenko <22616990+nvborisenko@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:10:14 +0300 Subject: [PATCH 2/2] Don't swallow not implemented exception, user should see it --- dotnet/src/webdriver/Logs.cs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/dotnet/src/webdriver/Logs.cs b/dotnet/src/webdriver/Logs.cs index 4ad943d9b7a44..6c903dccc9efd 100644 --- a/dotnet/src/webdriver/Logs.cs +++ b/dotnet/src/webdriver/Logs.cs @@ -76,29 +76,23 @@ public ReadOnlyCollection AvailableLogTypes public ReadOnlyCollection GetLog(string logKind) { List entries = new List(); - try - { - Dictionary parameters = new Dictionary(); - parameters.Add("type", logKind); - Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters); - object[] responseValue = commandResponse.Value as object[]; - if (responseValue != null) + Dictionary parameters = new Dictionary(); + 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 entryDictionary = rawEntry as Dictionary; + if (entryDictionary != null) { - Dictionary entryDictionary = rawEntry as Dictionary; - if (entryDictionary != null) - { - entries.Add(LogEntry.FromDictionary(entryDictionary)); - } + entries.Add(LogEntry.FromDictionary(entryDictionary)); } } } - catch (NotImplementedException) - { - // Swallow for backwards compatibility - } return entries.AsReadOnly(); }