From b54815e4c9c68a7680db1e0addaab9a6f470ad1c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 22 Jun 2022 18:56:23 +0000 Subject: [PATCH 1/2] Bump Newtonsoft.Json from 6.0.8 to 13.0.1 in /src/Winium.Desktop.Driver Bumps [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json) from 6.0.8 to 13.0.1. - [Release notes](https://github.com/JamesNK/Newtonsoft.Json/releases) - [Commits](https://github.com/JamesNK/Newtonsoft.Json/compare/6.0.8...13.0.1) --- updated-dependencies: - dependency-name: Newtonsoft.Json dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Winium.Desktop.Driver/packages.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Winium.Desktop.Driver/packages.config b/src/Winium.Desktop.Driver/packages.config index 0486d04..f06137c 100644 --- a/src/Winium.Desktop.Driver/packages.config +++ b/src/Winium.Desktop.Driver/packages.config @@ -3,7 +3,7 @@ - + From 5e911de60bb83b56c9023dd828e69fc73744d69a Mon Sep 17 00:00:00 2001 From: Arvin Juan <951273@corp.trizetto.com> Date: Fri, 6 Sep 2024 09:55:00 -0500 Subject: [PATCH 2/2] Updates for compatibility with Selenium 4 and Appium --- .../Automator/Automator.cs | 9 ++++- .../Automator/Capabilities.cs | 12 +++---- .../DoubleClickElementExecutor.cs | 17 +++++++++ .../CommandExecutors/NewSessionExecutor.cs | 35 ++++++++++++++++--- .../UriDispatchTables.cs | 3 ++ .../Winium.Desktop.Driver.csproj | 1 + src/Winium.StoreApps.Common/DriverCommand.cs | 6 ++++ .../JsonWireClasses.cs | 2 +- 8 files changed, 73 insertions(+), 12 deletions(-) create mode 100644 src/Winium.Desktop.Driver/CommandExecutors/DoubleClickElementExecutor.cs diff --git a/src/Winium.Desktop.Driver/Automator/Automator.cs b/src/Winium.Desktop.Driver/Automator/Automator.cs index 88f8d25..87ab45c 100644 --- a/src/Winium.Desktop.Driver/Automator/Automator.cs +++ b/src/Winium.Desktop.Driver/Automator/Automator.cs @@ -1,5 +1,6 @@ namespace Winium.Desktop.Driver.Automator { + using System; #region using using System.Collections.Generic; @@ -63,7 +64,13 @@ public static Automator InstanceForSession(string sessionId) { if (sessionId == null) { - sessionId = "AwesomeSession"; + Random random = new Random(); + string randomNumber = string.Empty; + for (int i = 0; i < 10; i++) + { + randomNumber += random.Next(0, 10).ToString(); + } + sessionId = randomNumber; } // TODO: Add actual support for sessions. Temporary return single Automator for any season diff --git a/src/Winium.Desktop.Driver/Automator/Capabilities.cs b/src/Winium.Desktop.Driver/Automator/Capabilities.cs index 8a6b2d7..5bd26ad 100644 --- a/src/Winium.Desktop.Driver/Automator/Capabilities.cs +++ b/src/Winium.Desktop.Driver/Automator/Capabilities.cs @@ -27,22 +27,22 @@ internal Capabilities() #region Public Properties - [JsonProperty("app")] + [JsonProperty("winium:app")] public string App { get; set; } - [JsonProperty("args")] + [JsonProperty("winium:args")] public string Arguments { get; set; } - [JsonProperty("debugConnectToRunningApp")] + [JsonProperty("winium:debugConnectToRunningApp")] public bool DebugConnectToRunningApp { get; set; } - [JsonProperty("innerPort")] + [JsonProperty("winium:innerPort")] public int InnerPort { get; set; } - [JsonProperty("keyboardSimulator")] + [JsonProperty("winium:keyboardSimulator")] public KeyboardSimulatorType KeyboardSimulator { get; set; } - [JsonProperty("launchDelay")] + [JsonProperty("winium:launchDelay")] public int LaunchDelay { get; set; } #endregion diff --git a/src/Winium.Desktop.Driver/CommandExecutors/DoubleClickElementExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/DoubleClickElementExecutor.cs new file mode 100644 index 0000000..fae15bc --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandExecutors/DoubleClickElementExecutor.cs @@ -0,0 +1,17 @@ +namespace Winium.Desktop.Driver.CommandExecutors +{ + internal class DoubleClickElementExecutor : CommandExecutorBase + { + #region Methods + + protected override string DoImpl() + { + var registeredKey = this.ExecutedCommand.Parameters["ID"].ToString(); + this.Automator.ElementsRegistry.GetRegisteredElement(registeredKey).DoubleClick(); + + return this.JsonResponse(); + } + + #endregion + } +} diff --git a/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs index e9b448a..43aa9fa 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs @@ -5,6 +5,7 @@ using System.Threading; using Newtonsoft.Json; + using Newtonsoft.Json.Linq; using Winium.Cruciatus; using Winium.Cruciatus.Settings; @@ -22,9 +23,13 @@ protected override string DoImpl() { // It is easier to reparse desired capabilities as JSON instead of re-mapping keys to attributes and calling type conversions, // so we will take possible one time performance hit by serializing Dictionary and deserializing it as Capabilities object - var serializedCapability = - JsonConvert.SerializeObject(this.ExecutedCommand.Parameters["desiredCapabilities"]); - this.Automator.ActualCapabilities = Capabilities.CapabilitiesFromJsonString(serializedCapability); + JObject cap = + JObject.Parse( + JsonConvert.SerializeObject( + this.ExecutedCommand.Parameters["capabilities"])); + var alwaysMatch = cap.SelectToken("alwaysMatch"); + this.Automator.ActualCapabilities = + Capabilities.CapabilitiesFromJsonString(alwaysMatch.ToString()); this.InitializeApplication(this.Automator.ActualCapabilities.DebugConnectToRunningApp); this.InitializeKeyboardEmulator(this.Automator.ActualCapabilities.KeyboardSimulator); @@ -32,7 +37,8 @@ protected override string DoImpl() // Gives sometime to load visuals (needed only in case of slow emulation) Thread.Sleep(this.Automator.ActualCapabilities.LaunchDelay); - return this.JsonResponse(ResponseStatus.Success, this.Automator.ActualCapabilities); + AutomatorResponse resp = new AutomatorResponse(this.Automator.Session, this.Automator.ActualCapabilities); + return this.JsonResponse(ResponseStatus.Success, resp); } private void InitializeApplication(bool debugDoNotDeploy = false) @@ -56,4 +62,25 @@ private void InitializeKeyboardEmulator(KeyboardSimulatorType keyboardSimulatorT #endregion } + + internal class AutomatorResponse + { + #region Constructors and Destructors + + public AutomatorResponse(string sessionId, Capabilities capabilities) + { + this.SessionId = sessionId; + this.Capabilities = capabilities; + } + #endregion + + #region Public Properties + + [JsonProperty("sessionId")] + public string SessionId { get; set; } + + [JsonProperty("capabilities")] + public Capabilities Capabilities { get; set; } + #endregion + } } diff --git a/src/Winium.Desktop.Driver/UriDispatchTables.cs b/src/Winium.Desktop.Driver/UriDispatchTables.cs index aa3e610..1eb994e 100644 --- a/src/Winium.Desktop.Driver/UriDispatchTables.cs +++ b/src/Winium.Desktop.Driver/UriDispatchTables.cs @@ -163,6 +163,9 @@ private void InitializeSeleniumCommandDictionary() this.commandDictionary.Add( DriverCommand.ClickElement, new CommandInfo("POST", "/session/{sessionId}/element/{id}/click")); + this.commandDictionary.Add( + DriverCommand.DoubleClickElement, + new CommandInfo("POST", "/session/{sessionId}/element/{id}/doubleClickElement")); this.commandDictionary.Add( DriverCommand.GetElementText, new CommandInfo("GET", "/session/{sessionId}/element/{id}/text")); diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index 1ad8823..ad9e97b 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -69,6 +69,7 @@ + diff --git a/src/Winium.StoreApps.Common/DriverCommand.cs b/src/Winium.StoreApps.Common/DriverCommand.cs index 2773f3f..39370ad 100644 --- a/src/Winium.StoreApps.Common/DriverCommand.cs +++ b/src/Winium.StoreApps.Common/DriverCommand.cs @@ -35,6 +35,12 @@ public static class DriverCommand /// public static readonly string ClickElement = "clickElement"; + /// + /// Represents DoubleClickElement command + /// + /// + public static readonly string DoubleClickElement = "doubleClickElement"; + /// /// Represents a Browser close command /// diff --git a/src/Winium.StoreApps.Common/JsonWireClasses.cs b/src/Winium.StoreApps.Common/JsonWireClasses.cs index 005311d..a0d7ca4 100644 --- a/src/Winium.StoreApps.Common/JsonWireClasses.cs +++ b/src/Winium.StoreApps.Common/JsonWireClasses.cs @@ -23,7 +23,7 @@ public JsonElementContent(string element) #region Public Properties - [JsonProperty("ELEMENT")] + [JsonProperty("element-6066-11e4-a52e-4f735466cecf")] public string Element { get; set; } #endregion