diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e523b4..94523fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,27 +1,34 @@ -# Change Log - - - - ## v1.5.0 - +# Change Log + + + + +## v1.6.0 + +- Fix exception Process Not Found in close/quit function +- Fix throw exceptions in getting some gui element's attributes + + +## v1.5.0 + - Add `SwitchToWindow` command -- Fix XPath attribute value if this ControlType - - -## v1.4.0 - +- Fix XPath attribute value if this ControlType + + +## v1.4.0 + - Add `XPath` strategy for locating elements - Add `GetCurrentWindowHandle` command - Add `GetWindowHandles` command - Add `--silent` option to a driver CLI (suppresses output) -- Fix logger timestamp format - - -## v1.3.0 - +- Fix logger timestamp format + + +## v1.3.0 + - Fix error response format - Add `args` capability for launching application with arguments - Set default elements search timeout to 10 seconds (fixed in [Winium.Cruciatus 2.7.0](https://github.com/2gis/Winium.Cruciatus/releases/tag/v2.7.0)) @@ -30,14 +37,14 @@ - ComboBox (collapse, expand, is expanded, find selected item, scroll to item) - DataGrid (row count, column count, find cell, scroll to cell, select cell) - ListBox (scroll to item) - - Menu (find item, select item) - - -## v1.2.0 - -New features: -- Support Action Chains from bindings -- Add new script command for setting value to element using ValuePattern - - - + - Menu (find item, select item) + + +## v1.2.0 + +New features: +- Support Action Chains from bindings +- Add new script command for setting value to element using ValuePattern + + + diff --git a/src/Winium.Desktop.Driver/CommandExecutors/CloseExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/CloseExecutor.cs index 4cbbacd..41d90b5 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/CloseExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/CloseExecutor.cs @@ -1,22 +1,18 @@ namespace Winium.Desktop.Driver.CommandExecutors { + #region using + + using Winium.Desktop.Driver.CommandHelpers; + + #endregion + internal class CloseExecutor : CommandExecutorBase { #region Methods protected override string DoImpl() { - if (!this.Automator.ActualCapabilities.DebugConnectToRunningApp) - { - if (!this.Automator.Application.Close()) - { - this.Automator.Application.Kill(); - } - - this.Automator.ElementsRegistry.Clear(); - } - - return this.JsonResponse(); + return TerminateApp.TerminateExcecutor(this.Automator, this.JsonResponse()); } #endregion diff --git a/src/Winium.Desktop.Driver/CommandExecutors/GetElementAttributeExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/GetElementAttributeExecutor.cs index 55af92c..b94af0a 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/GetElementAttributeExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/GetElementAttributeExecutor.cs @@ -39,6 +39,8 @@ protected override string DoImpl() * string, bool, int - should be as plain text * System.Windows.Automation.ControlType - should be used `ProgrammaticName` property * System.Window.Rect, System.Window.Point - overrides `ToString()` method, can serialize + * Int32[] array - use `string.Join()` method, can serialize + * enum - use `ToString()` method, can serialize */ private static object PrepareValueToSerialize(object obj) { @@ -58,6 +60,18 @@ private static object PrepareValueToSerialize(object obj) return controlType.ProgrammaticName; } + var intArray = obj as Int32[]; + if (intArray != null) + { + return string.Join(",", intArray); + } + + var intValue = obj as Enum; + if (intValue != null) + { + return intValue.ToString(); + } + return obj; } diff --git a/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs index e9b448a..982c73a 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/NewSessionExecutor.cs @@ -31,7 +31,7 @@ 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); } diff --git a/src/Winium.Desktop.Driver/CommandExecutors/QuitExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/QuitExecutor.cs index 59b6fb6..fa507be 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/QuitExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/QuitExecutor.cs @@ -1,22 +1,18 @@ namespace Winium.Desktop.Driver.CommandExecutors { + #region using + + using Winium.Desktop.Driver.CommandHelpers; + + #endregion + internal class QuitExecutor : CommandExecutorBase { #region Methods protected override string DoImpl() { - if (!this.Automator.ActualCapabilities.DebugConnectToRunningApp) - { - if (!this.Automator.Application.Close()) - { - this.Automator.Application.Kill(); - } - - this.Automator.ElementsRegistry.Clear(); - } - - return this.JsonResponse(); + return TerminateApp.TerminateExcecutor(this.Automator, this.JsonResponse()); } #endregion diff --git a/src/Winium.Desktop.Driver/CommandHelpers/TerminateApp.cs b/src/Winium.Desktop.Driver/CommandHelpers/TerminateApp.cs new file mode 100644 index 0000000..3855a28 --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandHelpers/TerminateApp.cs @@ -0,0 +1,45 @@ +namespace Winium.Desktop.Driver.CommandHelpers +{ + #region using + + using System.Collections.Generic; + using System.Diagnostics; + + using Winium.Desktop.Driver.Automator; + + #endregion + + public static class TerminateApp + { + public static string TerminateExcecutor(object automatorObject, string jsonResponse) + { + Automator automator = (Automator)automatorObject; + if (!automator.ActualCapabilities.DebugConnectToRunningApp) + { + // If application had exited, find and terminate all children processes + if (automator.Application.HasExited()) + { + List children = new List(); + children = automator.Application.GetChildPrecesses(automator.Application.GetProcessId()); + foreach (var child in children) + { + if (!child.HasExited && !automator.Application.Close(child)) + { + automator.Application.Kill(child); + } + } + } + + // If application is still running, terminate it as normal case + else if (!automator.Application.Close()) + { + automator.Application.Kill(); + } + + automator.ElementsRegistry.Clear(); + } + + return jsonResponse; + } + } +} diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index a6bcf99..10f5fe0 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -116,6 +116,7 @@ +