From 494aa4cdf7ffd22934f996bbe000787511a58b61 Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Fri, 16 Oct 2015 01:26:52 +0300 Subject: [PATCH 1/3] SwitchToWindow command implementation --- .../SwitchToWindowExecutor.cs | 30 +++++++++++++++++++ .../Winium.Desktop.Driver.csproj | 1 + 2 files changed, 31 insertions(+) create mode 100644 src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs diff --git a/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs new file mode 100644 index 0000000..febdae3 --- /dev/null +++ b/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs @@ -0,0 +1,30 @@ +namespace Winium.Desktop.Driver.CommandExecutors +{ + #region using + + using System.Windows.Automation; + + using Winium.Cruciatus; + using Winium.Cruciatus.Core; + + #endregion + + internal class SwitchToWindowExecutor : CommandExecutorBase + { + #region Methods + + protected override string DoImpl() + { + var windowHandle = int.Parse(this.ExecutedCommand.Parameters["name"].ToString()); + + var handleProperty = AutomationElement.NativeWindowHandleProperty; + var window = CruciatusFactory.Root.FindElement(By.AutomationProperty(handleProperty, windowHandle)); + + window.SetFocus(); + + return this.JsonResponse(); + } + + #endregion + } +} diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index 204cdf0..6cdad82 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -112,6 +112,7 @@ + From 3a0b2e00f5aec665fe1c4bc167952e82cf6517b5 Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Mon, 19 Oct 2015 18:56:29 +0300 Subject: [PATCH 2/3] Winium.Cruciatus version up --- src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj | 2 +- src/Winium.Desktop.Driver/packages.config | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index 6cdad82..b144a63 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -62,7 +62,7 @@ True - ..\packages\Winium.Cruciatus.2.8.0\lib\net45\Winium.Cruciatus.dll + ..\packages\Winium.Cruciatus.2.9.0\lib\net45\Winium.Cruciatus.dll True diff --git a/src/Winium.Desktop.Driver/packages.config b/src/Winium.Desktop.Driver/packages.config index 3828315..3ee3049 100644 --- a/src/Winium.Desktop.Driver/packages.config +++ b/src/Winium.Desktop.Driver/packages.config @@ -6,5 +6,5 @@ - + \ No newline at end of file From 005e905a833cd069c09dadd946c55a51003c24f2 Mon Sep 17 00:00:00 2001 From: zebraxxl Date: Tue, 20 Oct 2015 11:43:00 +0300 Subject: [PATCH 3/3] Winium.Cruciatus update and checking for not founded window --- .../CommandExecutors/SwitchToWindowExecutor.cs | 7 ++++++- src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj | 2 +- src/Winium.Desktop.Driver/packages.config | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs b/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs index febdae3..efbe20d 100644 --- a/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs +++ b/src/Winium.Desktop.Driver/CommandExecutors/SwitchToWindowExecutor.cs @@ -3,9 +3,10 @@ #region using using System.Windows.Automation; - using Winium.Cruciatus; using Winium.Cruciatus.Core; + using Winium.StoreApps.Common; + using Winium.StoreApps.Common.Exceptions; #endregion @@ -19,6 +20,10 @@ protected override string DoImpl() var handleProperty = AutomationElement.NativeWindowHandleProperty; var window = CruciatusFactory.Root.FindElement(By.AutomationProperty(handleProperty, windowHandle)); + if (window == null) + { + throw new AutomationException("Window cannot be found", ResponseStatus.NoSuchElement); + } window.SetFocus(); diff --git a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj index b144a63..bf71cd7 100644 --- a/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj +++ b/src/Winium.Desktop.Driver/Winium.Desktop.Driver.csproj @@ -62,7 +62,7 @@ True - ..\packages\Winium.Cruciatus.2.9.0\lib\net45\Winium.Cruciatus.dll + ..\packages\Winium.Cruciatus.2.9.1\lib\net45\Winium.Cruciatus.dll True diff --git a/src/Winium.Desktop.Driver/packages.config b/src/Winium.Desktop.Driver/packages.config index 3ee3049..8a2562a 100644 --- a/src/Winium.Desktop.Driver/packages.config +++ b/src/Winium.Desktop.Driver/packages.config @@ -6,5 +6,5 @@ - + \ No newline at end of file